{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "388dc199-dc81-4f40-abb0-c8cd91a47ebb",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T06:49:37.808326Z",
     "iopub.status.busy": "2022-03-15T06:49:37.807951Z",
     "iopub.status.idle": "2022-03-15T06:49:40.096440Z",
     "shell.execute_reply": "2022-03-15T06:49:40.095763Z",
     "shell.execute_reply.started": "2022-03-15T06:49:37.808247Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2022-03-15 14:49:39.156143: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library libcudart.so.11.0\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "from sentence_transformers import InputExample, SentenceTransformer\n",
    "from torch.utils.data import DataLoader"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d45c8a77-f8ce-4e37-b1c3-ce59a0081890",
   "metadata": {
    "tags": []
   },
   "source": [
    "## 读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "8ee54a48-4f6c-4517-99d9-5c2c74413bb2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T06:49:41.234210Z",
     "iopub.status.busy": "2022-03-15T06:49:41.233761Z",
     "iopub.status.idle": "2022-03-15T06:49:42.725286Z",
     "shell.execute_reply": "2022-03-15T06:49:42.724780Z",
     "shell.execute_reply.started": "2022-03-15T06:49:41.234161Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "corpus_data = pd.read_csv(\"./input/corpus.tsv\", sep=\"\\t\", names=[\"doc\", \"title\"])\n",
    "dev_data = pd.read_csv(\"./input/dev.query.txt\", sep=\"\\t\", names=[\"query\", \"title\"])\n",
    "train_data = pd.read_csv(\"./input/train.query.txt\", sep=\"\\t\", names=[\"query\", \"title\"])\n",
    "qrels = pd.read_csv(\"./input/qrels.train.tsv\", sep=\"\\t\", names=[\"query\", \"doc\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "15a6db06-1215-43a8-a2cd-8e5d16abc0a0",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T06:49:42.726832Z",
     "iopub.status.busy": "2022-03-15T06:49:42.726688Z",
     "iopub.status.idle": "2022-03-15T06:49:42.759920Z",
     "shell.execute_reply": "2022-03-15T06:49:42.759077Z",
     "shell.execute_reply.started": "2022-03-15T06:49:42.726816Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "corpus_data = corpus_data.set_index(\"doc\")\n",
    "dev_data = dev_data.set_index(\"query\")\n",
    "train_data = train_data.set_index(\"query\")\n",
    "qrels = qrels.set_index(\"query\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "f95cdcf5-4adf-4c5e-b691-1c92a9a823d7",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T06:49:42.760769Z",
     "iopub.status.busy": "2022-03-15T06:49:42.760640Z",
     "iopub.status.idle": "2022-03-15T06:49:42.809503Z",
     "shell.execute_reply": "2022-03-15T06:49:42.808704Z",
     "shell.execute_reply.started": "2022-03-15T06:49:42.760753Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "# corpus_data_copy = corpus_data.copy()\n",
    "# corpus_data_copy['title_len'] = corpus_data_copy['title'].apply(len)\n",
    "# noise_title = corpus_data_copy[corpus_data_copy['title_len'] < 10]['title'].values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "b3253067-1545-4f09-b035-e41856f746a7",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T06:49:42.811689Z",
     "iopub.status.busy": "2022-03-15T06:49:42.811510Z",
     "iopub.status.idle": "2022-03-15T06:49:42.871687Z",
     "shell.execute_reply": "2022-03-15T06:49:42.870855Z",
     "shell.execute_reply.started": "2022-03-15T06:49:42.811672Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "# len(noise_title)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "316c51e2-fef7-4f1e-9afa-60b81cea0fbb",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T06:49:42.872915Z",
     "iopub.status.busy": "2022-03-15T06:49:42.872617Z",
     "iopub.status.idle": "2022-03-15T06:49:42.948504Z",
     "shell.execute_reply": "2022-03-15T06:49:42.947890Z",
     "shell.execute_reply.started": "2022-03-15T06:49:42.872888Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>doc</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>铂盛弹盖文艺保温杯学生男女情侣车载时尚英文锁扣不锈钢真空水杯</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>可爱虎子华为荣耀X30i手机壳荣耀x30防摔全包镜头honorx30max液态硅胶虎年情侣女...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>190色素色亚麻棉平纹布料 衬衫裙服装定制手工绣花面料 汇典亚麻</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>松尼合金木工开孔器实木门开锁孔木板圆形打空神器定位打孔钻头</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>微钩绿蝴蝶材料包非成品 赠送视频组装教程 需自备钩针染料</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                 title\n",
       "doc                                                   \n",
       "1                       铂盛弹盖文艺保温杯学生男女情侣车载时尚英文锁扣不锈钢真空水杯\n",
       "2    可爱虎子华为荣耀X30i手机壳荣耀x30防摔全包镜头honorx30max液态硅胶虎年情侣女...\n",
       "3                     190色素色亚麻棉平纹布料 衬衫裙服装定制手工绣花面料 汇典亚麻\n",
       "4                        松尼合金木工开孔器实木门开锁孔木板圆形打空神器定位打孔钻头\n",
       "5                         微钩绿蝴蝶材料包非成品 赠送视频组装教程 需自备钩针染料"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "corpus_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "13077d00-f9ee-4554-afc4-0be515a6ca6e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T06:49:43.278220Z",
     "iopub.status.busy": "2022-03-15T06:49:43.277692Z",
     "iopub.status.idle": "2022-03-15T06:49:43.287742Z",
     "shell.execute_reply": "2022-03-15T06:49:43.287268Z",
     "shell.execute_reply.started": "2022-03-15T06:49:43.278169Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>query</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>200001</th>\n",
       "      <td>甲黄酸阿怕替尼片</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>200002</th>\n",
       "      <td>索泰zbox</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>200003</th>\n",
       "      <td>kfc游戏机</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>200004</th>\n",
       "      <td>bunny成兔粮</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>200005</th>\n",
       "      <td>铁线威灵仙</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             title\n",
       "query             \n",
       "200001   甲黄酸阿怕替尼片 \n",
       "200002     索泰zbox \n",
       "200003     kfc游戏机 \n",
       "200004   bunny成兔粮 \n",
       "200005      铁线威灵仙 "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dev_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "4557ac3e-2863-4147-9d4f-5729191d9a70",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T06:49:43.932289Z",
     "iopub.status.busy": "2022-03-15T06:49:43.931867Z",
     "iopub.status.idle": "2022-03-15T06:49:43.942287Z",
     "shell.execute_reply": "2022-03-15T06:49:43.941633Z",
     "shell.execute_reply.started": "2022-03-15T06:49:43.932240Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>query</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美赞臣亲舒一段</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>慱朗手动料理机</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>電力貓</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>掏夹缝工具</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>飞推vip</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         title\n",
       "query         \n",
       "1      美赞臣亲舒一段\n",
       "2      慱朗手动料理机\n",
       "3          電力貓\n",
       "4        掏夹缝工具\n",
       "5        飞推vip"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "1abf200f-9f3d-44c2-8f6d-e510f7761d8f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T06:49:44.572577Z",
     "iopub.status.busy": "2022-03-15T06:49:44.572179Z",
     "iopub.status.idle": "2022-03-15T06:49:44.583281Z",
     "shell.execute_reply": "2022-03-15T06:49:44.582796Z",
     "shell.execute_reply.started": "2022-03-15T06:49:44.572527Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>doc</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>query</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>679139</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>35343</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>781652</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>557516</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>588014</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          doc\n",
       "query        \n",
       "1      679139\n",
       "2       35343\n",
       "3      781652\n",
       "4      557516\n",
       "5      588014"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "qrels.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "095232eb-f2fb-4fb7-bf83-e4f9bbf28050",
   "metadata": {},
   "source": [
    "## 分词"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "5db97207-8dc8-42bf-a5e5-b187d4da774d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T06:49:45.851898Z",
     "iopub.status.busy": "2022-03-15T06:49:45.851473Z",
     "iopub.status.idle": "2022-03-15T06:49:46.379845Z",
     "shell.execute_reply": "2022-03-15T06:49:46.379436Z",
     "shell.execute_reply.started": "2022-03-15T06:49:45.851849Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Building prefix dict from the default dictionary ...\n",
      "Loading model from cache /tmp/jieba.cache\n",
      "Loading model cost 0.510 seconds.\n",
      "Prefix dict has been built successfully.\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'美赞臣 亲舒 一段'"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import jieba\n",
    "\n",
    "\" \".join(jieba.cut(\"美赞臣亲舒一段\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "b51f2846-13e4-42d7-b792-9f11e488fbba",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T06:49:50.081892Z",
     "iopub.status.busy": "2022-03-15T06:49:50.081444Z",
     "iopub.status.idle": "2022-03-15T06:50:15.228310Z",
     "shell.execute_reply": "2022-03-15T06:50:15.227905Z",
     "shell.execute_reply.started": "2022-03-15T06:49:50.081840Z"
    },
    "scrolled": true,
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Building prefix dict from the default dictionary ...\n",
      "Loading model from cache /tmp/jieba.cache\n",
      "Building prefix dict from the default dictionary ...\n",
      "Loading model from cache /tmp/jieba.cache\n",
      "Building prefix dict from the default dictionary ...\n",
      "Loading model from cache /tmp/jieba.cache\n",
      "Building prefix dict from the default dictionary ...\n",
      "Loading model from cache /tmp/jieba.cache\n",
      "Building prefix dict from the default dictionary ...\n",
      "Loading model from cache /tmp/jieba.cache\n",
      "Building prefix dict from the default dictionary ...\n",
      "Loading model from cache /tmp/jieba.cache\n",
      "Building prefix dict from the default dictionary ...\n",
      "Loading model from cache /tmp/jieba.cache\n",
      "Building prefix dict from the default dictionary ...\n",
      "Loading model from cache /tmp/jieba.cache\n",
      "Building prefix dict from the default dictionary ...\n",
      "Loading model from cache /tmp/jieba.cache\n",
      "Building prefix dict from the default dictionary ...\n",
      "Loading model from cache /tmp/jieba.cache\n",
      "Building prefix dict from the default dictionary ...\n",
      "Loading model from cache /tmp/jieba.cache\n",
      "Building prefix dict from the default dictionary ...\n",
      "Loading model from cache /tmp/jieba.cache\n",
      "Loading model cost 0.979 seconds.\n",
      "Prefix dict has been built successfully.\n",
      "Loading model cost 1.004 seconds.\n",
      "Prefix dict has been built successfully.\n",
      "Loading model cost 1.006 seconds.\n",
      "Prefix dict has been built successfully.\n",
      "Loading model cost 1.053 seconds.\n",
      "Prefix dict has been built successfully.\n",
      "Loading model cost 0.990 seconds.\n",
      "Prefix dict has been built successfully.\n",
      "Loading model cost 0.960 seconds.\n",
      "Prefix dict has been built successfully.\n",
      "Loading model cost 0.991 seconds.\n",
      "Prefix dict has been built successfully.\n",
      "Loading model cost 1.019 seconds.\n",
      "Prefix dict has been built successfully.\n",
      "Loading model cost 1.013 seconds.\n",
      "Prefix dict has been built successfully.\n",
      "Loading model cost 0.998 seconds.\n",
      "Prefix dict has been built successfully.\n",
      "Loading model cost 0.955 seconds.\n",
      "Prefix dict has been built successfully.\n",
      "Loading model cost 0.984 seconds.\n",
      "Prefix dict has been built successfully.\n"
     ]
    }
   ],
   "source": [
    "def title_cut(x):\n",
    "    return list(jieba.cut(x))\n",
    "\n",
    "\n",
    "from joblib import Parallel, delayed\n",
    "\n",
    "corpus_title = Parallel(n_jobs=-1)(\n",
    "    delayed(title_cut)(title) for title in corpus_data[\"title\"]\n",
    ")\n",
    "train_title = Parallel(n_jobs=-1)(\n",
    "    delayed(title_cut)(title) for title in train_data[\"title\"]\n",
    ")\n",
    "# dev_title = dev_data['title'].apply(title_cut)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ab9e9154-99d8-40b3-8aa8-bc02456efe03",
   "metadata": {},
   "source": [
    "## IDF"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "9930b12e-83ec-4777-8243-693167fb15b8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:08:37.828012Z",
     "iopub.status.busy": "2022-03-15T07:08:37.827446Z",
     "iopub.status.idle": "2022-03-15T07:08:38.248945Z",
     "shell.execute_reply": "2022-03-15T07:08:38.248511Z",
     "shell.execute_reply.started": "2022-03-15T07:08:37.827952Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "TfidfVectorizer(analyzer=<function <lambda> at 0x7f9fa4911940>)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.feature_extraction.text import TfidfVectorizer\n",
    "\n",
    "idf = TfidfVectorizer(analyzer=lambda x: x)\n",
    "idf.fit(train_title)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "664063bf-6d1c-49eb-99b8-0c3a0bbd155b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:08:38.826855Z",
     "iopub.status.busy": "2022-03-15T07:08:38.826321Z",
     "iopub.status.idle": "2022-03-15T07:08:38.894531Z",
     "shell.execute_reply": "2022-03-15T07:08:38.894042Z",
     "shell.execute_reply.started": "2022-03-15T07:08:38.826802Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/lyz/.local/lib/python3.9/site-packages/sklearn/utils/deprecation.py:87: FutureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated in 1.0 and will be removed in 1.2. Please use get_feature_names_out instead.\n",
      "  warnings.warn(msg, category=FutureWarning)\n"
     ]
    }
   ],
   "source": [
    "vocab = idf.get_feature_names()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "b9d5ca8d-34f4-42d9-811d-6e1e749c0a0a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:08:39.825154Z",
     "iopub.status.busy": "2022-03-15T07:08:39.824599Z",
     "iopub.status.idle": "2022-03-15T07:08:40.518339Z",
     "shell.execute_reply": "2022-03-15T07:08:40.517620Z",
     "shell.execute_reply.started": "2022-03-15T07:08:39.825093Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[60517, 17245, 14225], [37210, 42871, 37525, 40991, 43206]]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_ids = [[idf.vocabulary_[x] for x in title] for title in train_title]\n",
    "train_ids[:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "86e1b38c-e08c-4b64-acb9-a900eede997c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:08:40.519323Z",
     "iopub.status.busy": "2022-03-15T07:08:40.519197Z",
     "iopub.status.idle": "2022-03-15T07:08:40.817553Z",
     "shell.execute_reply": "2022-03-15T07:08:40.816991Z",
     "shell.execute_reply.started": "2022-03-15T07:08:40.519307Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([ 4.14517079, 11.81978828, 10.721176  , ..., 11.81978828,\n",
       "        11.81978828, 11.81978828]),\n",
       " 77509)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "idf.idf_, len(idf.idf_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "9994039c-2944-45c4-8bac-9f276b851288",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:08:40.830193Z",
     "iopub.status.busy": "2022-03-15T07:08:40.829935Z",
     "iopub.status.idle": "2022-03-15T07:08:49.031265Z",
     "shell.execute_reply": "2022-03-15T07:08:49.030757Z",
     "shell.execute_reply.started": "2022-03-15T07:08:40.830175Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "corpus_idf = idf.transform(corpus_title)\n",
    "train_idf = idf.transform(train_title)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "083ca5e7-510a-4b9c-8d39-d32a6c81b770",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:08:49.032394Z",
     "iopub.status.busy": "2022-03-15T07:08:49.032257Z",
     "iopub.status.idle": "2022-03-15T07:08:49.036203Z",
     "shell.execute_reply": "2022-03-15T07:08:49.035788Z",
     "shell.execute_reply.started": "2022-03-15T07:08:49.032378Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[60517, 17245, 14225]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[idf.vocabulary_[x] for x in train_title[0]]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e21fb836-283c-4679-8164-8ccbedb6f216",
   "metadata": {},
   "source": [
    "## 负样本构造"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "45cd0cb4-682d-4923-b237-e0c0077772b8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:08:49.038374Z",
     "iopub.status.busy": "2022-03-15T07:08:49.037620Z",
     "iopub.status.idle": "2022-03-15T07:08:49.146398Z",
     "shell.execute_reply": "2022-03-15T07:08:49.145957Z",
     "shell.execute_reply.started": "2022-03-15T07:08:49.038325Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([  1009,  26789,  41852,  57032,  94147, 116564, 127764, 166304,\n",
       "        191889, 236547, 257511, 280519, 285231, 285492, 303973, 345935,\n",
       "        369300, 433723, 435556, 499075, 519905, 550179, 572794, 574646,\n",
       "        614743, 623935, 679138, 681825, 699256, 735695, 754510, 763358,\n",
       "        773570, 839213, 845106, 869273, 922629, 926762, 961398, 987809,\n",
       "        997086], dtype=int32),\n",
       " array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
       "       dtype=int32))"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(corpus_idf[:, 60517] != 0).nonzero()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "706c3022-223d-4dec-8912-604a799a4931",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:08:49.147922Z",
     "iopub.status.busy": "2022-03-15T07:08:49.147689Z",
     "iopub.status.idle": "2022-03-15T07:08:49.160612Z",
     "shell.execute_reply": "2022-03-15T07:08:49.160305Z",
     "shell.execute_reply.started": "2022-03-15T07:08:49.147906Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('美赞臣亲舒一段', '有现货美国美赞臣Enfamil婴幼儿宝宝多维综合维生素滴剂含铁50ML')"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data[\"title\"].iloc[0], corpus_data[\"title\"].iloc[926762]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "6188f87c-2f03-44b1-a437-a785bc18bdc3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:08:49.161275Z",
     "iopub.status.busy": "2022-03-15T07:08:49.161102Z",
     "iopub.status.idle": "2022-03-15T07:08:54.683883Z",
     "shell.execute_reply": "2022-03-15T07:08:54.683426Z",
     "shell.execute_reply.started": "2022-03-15T07:08:49.161259Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "keyword_corpus_idxs, keyword_idxs = corpus_idf.nonzero()\n",
    "inverse_keyword_map = {}\n",
    "for x, y in zip(keyword_idxs, keyword_corpus_idxs):\n",
    "    if vocab[x] in inverse_keyword_map:\n",
    "        inverse_keyword_map[vocab[x]].append(y)\n",
    "    else:\n",
    "        inverse_keyword_map[vocab[x]] = [y]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "52307dde-519b-4af6-99bc-2f6f214087b7",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:08:54.684806Z",
     "iopub.status.busy": "2022-03-15T07:08:54.684678Z",
     "iopub.status.idle": "2022-03-15T07:08:54.742847Z",
     "shell.execute_reply": "2022-03-15T07:08:54.742410Z",
     "shell.execute_reply.started": "2022-03-15T07:08:54.684790Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "vocab = idf.get_feature_names()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "5cc4727b-0f07-4a5f-8046-4a6aa05fdfce",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:08:54.743685Z",
     "iopub.status.busy": "2022-03-15T07:08:54.743480Z",
     "iopub.status.idle": "2022-03-15T07:08:54.804654Z",
     "shell.execute_reply": "2022-03-15T07:08:54.803862Z",
     "shell.execute_reply.started": "2022-03-15T07:08:54.743668Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('公文包', 20001)"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vocab[20001], idf.vocabulary_[\"公文包\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "9fd8ccdf-c21d-4228-b457-8da69b55a515",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:08:54.806115Z",
     "iopub.status.busy": "2022-03-15T07:08:54.805893Z",
     "iopub.status.idle": "2022-03-15T07:08:55.905262Z",
     "shell.execute_reply": "2022-03-15T07:08:55.904837Z",
     "shell.execute_reply.started": "2022-03-15T07:08:54.806100Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((1001500, 77509), 1001499, 77466)"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "corpus_idf.shape, max(keyword_corpus_idxs), max(keyword_idxs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "4c13601a-f4f3-4f36-9e62-bb530798029b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:11:31.931505Z",
     "iopub.status.busy": "2022-03-15T07:11:31.930958Z",
     "iopub.status.idle": "2022-03-15T07:11:31.936560Z",
     "shell.execute_reply": "2022-03-15T07:11:31.935589Z",
     "shell.execute_reply.started": "2022-03-15T07:11:31.931454Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "from tqdm import tqdm_notebook"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "14a52384-78db-4f6d-97fb-9780276f172a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:11:43.150283Z",
     "iopub.status.busy": "2022-03-15T07:11:43.149701Z",
     "iopub.status.idle": "2022-03-15T07:12:35.127208Z",
     "shell.execute_reply": "2022-03-15T07:12:35.126719Z",
     "shell.execute_reply.started": "2022-03-15T07:11:43.150232Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_23111/3571231614.py:4: TqdmDeprecationWarning: This function will be removed in tqdm==5.0.0\n",
      "Please use `tqdm.notebook.tqdm` instead of `tqdm.tqdm_notebook`\n",
      "  for idx in tqdm_notebook(range(1, train_data.shape[0] + 1 - 5000)):\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "e39114dc9c7147e389dbf8701d885ccd",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/95000 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "MAX_NEG_SAMPLES = 10\n",
    "\n",
    "train_neg_piar = []\n",
    "for idx in tqdm_notebook(range(1, train_data.shape[0] + 1 - 5000)):\n",
    "    idx_keyword = train_title[idx - 1]\n",
    "    idx_keyword_idf = idf.idf_[train_ids[idx - 1]]\n",
    "    idx_top1_word = idx_keyword[idx_keyword_idf.argmax()]\n",
    "    # idx_start_word, idx_end_word = idx_keyword[0], idx_keyword[-1]\n",
    "\n",
    "    if idx_top1_word in inverse_keyword_map:\n",
    "        negative_idx = inverse_keyword_map[idx_top1_word][:MAX_NEG_SAMPLES]\n",
    "    else:\n",
    "        negative_idx = np.random.randint(corpus_data.shape[0], size=MAX_NEG_SAMPLES)\n",
    "\n",
    "    \"\"\"\n",
    "    idx_keyword = []\n",
    "    if len(idx_top1_word) >= 2 and idx_top1_word in inverse_keyword_map:\n",
    "        idx_keyword += inverse_keyword_map[idx_top1_word]\n",
    "    if len(idx_start_word) >= 2 and idx_start_word in inverse_keyword_map:\n",
    "        idx_keyword += inverse_keyword_map[idx_start_word]\n",
    "    if len(idx_end_word) >= 2 and idx_end_word in inverse_keyword_map:\n",
    "        idx_keyword += inverse_keyword_map[idx_end_word]\n",
    "    negative_idx = sum(negative_idx, [])\n",
    "    \"\"\"\n",
    "\n",
    "    # negative_idx = list(set(negative_idx))\n",
    "    negative_idx = [x + 1 for x in negative_idx]\n",
    "    positive_idx = qrels.loc[idx].ravel()[0]\n",
    "    if positive_idx in negative_idx:\n",
    "        negative_idx.remove(positive_idx)\n",
    "\n",
    "    train_neg_piar.append(negative_idx)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "4db26224-4e71-4a8e-909d-46f22d826c70",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:12:37.930161Z",
     "iopub.status.busy": "2022-03-15T07:12:37.929708Z",
     "iopub.status.idle": "2022-03-15T07:12:37.937908Z",
     "shell.execute_reply": "2022-03-15T07:12:37.936966Z",
     "shell.execute_reply.started": "2022-03-15T07:12:37.930108Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'江玲'"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "idx_keyword[idx_keyword_idf.argmax()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "56aad54a-8140-499d-b207-c9296808d4f3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:12:38.927551Z",
     "iopub.status.busy": "2022-03-15T07:12:38.927129Z",
     "iopub.status.idle": "2022-03-15T07:12:38.934489Z",
     "shell.execute_reply": "2022-03-15T07:12:38.934046Z",
     "shell.execute_reply.started": "2022-03-15T07:12:38.927501Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "positive_idx in negative_idx"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "c41f9c28-b221-4dcd-88d6-6a4016064b4d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:12:39.932374Z",
     "iopub.status.busy": "2022-03-15T07:12:39.931957Z",
     "iopub.status.idle": "2022-03-15T07:12:39.943581Z",
     "shell.execute_reply": "2022-03-15T07:12:39.942944Z",
     "shell.execute_reply.started": "2022-03-15T07:12:39.932326Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "title    江铃尿素江铃柴油车专用尿素通用柴油车国五国六尿素春节后发货哦\n",
       "Name: 188941, dtype: object"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "corpus_data.loc[qrels.loc[idx].ravel()[0]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "5ca91b0a-9440-4b05-be7f-04f46dac460e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:12:40.929067Z",
     "iopub.status.busy": "2022-03-15T07:12:40.928653Z",
     "iopub.status.idle": "2022-03-15T07:12:40.964423Z",
     "shell.execute_reply": "2022-03-15T07:12:40.963927Z",
     "shell.execute_reply.started": "2022-03-15T07:12:40.929018Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>doc</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>296459</th>\n",
       "      <td>江玲宝典皮卡江铃e100电动3域虎5e200汽车驭胜S350专用手机支架</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                       title\n",
       "doc                                         \n",
       "296459  江玲宝典皮卡江铃e100电动3域虎5e200汽车驭胜S350专用手机支架"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "corpus_data.loc[negative_idx]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0e639e6b-77c3-49c9-a265-507ebd3232bd",
   "metadata": {},
   "source": [
    "## 训练集构造"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "0b50db5c-ffb8-43e5-badd-a45145fb0702",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:13:15.094682Z",
     "iopub.status.busy": "2022-03-15T07:13:15.094247Z",
     "iopub.status.idle": "2022-03-15T07:13:18.909484Z",
     "shell.execute_reply": "2022-03-15T07:13:18.909028Z",
     "shell.execute_reply.started": "2022-03-15T07:13:15.094633Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_23111/3040503206.py:5: TqdmDeprecationWarning: This function will be removed in tqdm==5.0.0\n",
      "Please use `tqdm.notebook.tqdm` instead of `tqdm.tqdm_notebook`\n",
      "  for idx in tqdm_notebook(range(1, 1000)):\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "2862b60d3a8a4af7acf95d408f8ecd86",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/999 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from tqdm import tqdm_notebook\n",
    "\n",
    "train_examples = []\n",
    "# for idx in tqdm_notebook(range(1, train_data.shape[0] + 1 - 5000)):\n",
    "for idx in tqdm_notebook(range(1, 1000)):\n",
    "\n",
    "    train_examples.append(\n",
    "        InputExample(\n",
    "            texts=[\n",
    "                train_data.loc[idx][\"title\"],\n",
    "                corpus_data.loc[qrels.loc[idx].ravel()[0]][\"title\"],\n",
    "            ],\n",
    "            label=1.0,\n",
    "        )\n",
    "    )\n",
    "    \n",
    "    if idx-1 in train_neg_piar:\n",
    "        for neg_idx in train_neg_piar[idx-1]:\n",
    "            if neg_idx % 2 == 0:\n",
    "                train_examples.append(\n",
    "                    InputExample(\n",
    "                        texts=[\n",
    "                            train_data.loc[idx][\"title\"],\n",
    "                            corpus_data.loc[neg_idx][\"title\"],\n",
    "                        ],\n",
    "                        label=0.0,\n",
    "                    )\n",
    "                )\n",
    "            else:\n",
    "                train_examples.append(\n",
    "                    InputExample(\n",
    "                        texts=[\n",
    "                            corpus_data.loc[neg_idx][\"title\"],\n",
    "                            train_data.loc[idx][\"title\"],\n",
    "\n",
    "                        ],\n",
    "                        label=0.0,\n",
    "                    )\n",
    "                )\n",
    "        \n",
    "    rand_idx = np.random.randint(1, corpus_data.shape[0], size=20)\n",
    "    for neg_idx in rand_idx:\n",
    "        train_examples.append(\n",
    "            InputExample(\n",
    "                texts=[\n",
    "                    train_data.loc[idx][\"title\"],\n",
    "                    corpus_data.loc[neg_idx][\"title\"],\n",
    "                ],\n",
    "                label=0.0,\n",
    "            )\n",
    "        )\n",
    "        \n",
    "        \n",
    "        # print(corpus_data.loc[neg_idx][\"title\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "85e56afb-50c9-427f-a96b-1a1729319ab3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:13:21.925678Z",
     "iopub.status.busy": "2022-03-15T07:13:21.925260Z",
     "iopub.status.idle": "2022-03-15T07:13:21.933115Z",
     "shell.execute_reply": "2022-03-15T07:13:21.932554Z",
     "shell.execute_reply.started": "2022-03-15T07:13:21.925629Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['<InputExample> label: 1.0, texts: 美赞臣亲舒一段; 领券满减】美赞臣安婴儿A+亲舒 婴儿奶粉1段850克 0-12个月宝宝',\n",
       " '<InputExample> label: 0.0, texts: 美赞臣亲舒一段; 印章收纳包营业执照收纳包大容量带密码锁多格印章执照一体包便携',\n",
       " '<InputExample> label: 0.0, texts: 美赞臣亲舒一段; 加厚加大号铁书立/学生书夹书挡书靠书立书架办公桌面收纳黑白色',\n",
       " '<InputExample> label: 0.0, texts: 美赞臣亲舒一段; 欧式实木茶几2.4米电视柜2.2米客厅组合小户型橡木法式香槟色家具',\n",
       " '<InputExample> label: 0.0, texts: 美赞臣亲舒一段; 夏季港风复古chic盐系网红炸街小个子休闲上衣职业短裤两件套装女',\n",
       " '<InputExample> label: 0.0, texts: 美赞臣亲舒一段; 模具加工定做订做 来图来样免费设计出图注塑制作 塑料制品开模',\n",
       " '<InputExample> label: 0.0, texts: 美赞臣亲舒一段; 适用于雪佛兰赛欧3大灯罩15-18款赛欧3前大灯透明灯罩赛欧3大灯壳',\n",
       " '<InputExample> label: 0.0, texts: 美赞臣亲舒一段; 百乐满极光平衡式燃气热水器，16升、20升、24升，不懂用多',\n",
       " '<InputExample> label: 0.0, texts: 美赞臣亲舒一段; 适用于宝马E53 E70后下摆臂胶 E60 520 525 530 730 740后H臂胶套',\n",
       " '<InputExample> label: 0.0, texts: 美赞臣亲舒一段; 扬子洲 林可霉素利多卡因凝胶 20g*1支/盒 轻度烧伤创伤 蚊虫叮咬']"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[str(x) for x in train_examples[:10]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "b21b8dab-e07d-4ca8-86b5-6d64fe4dc20b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:13:28.294799Z",
     "iopub.status.busy": "2022-03-15T07:13:28.294345Z",
     "iopub.status.idle": "2022-03-15T07:13:28.300744Z",
     "shell.execute_reply": "2022-03-15T07:13:28.299896Z",
     "shell.execute_reply.started": "2022-03-15T07:13:28.294763Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[987810]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_neg_piar[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ce044b10-287f-49f2-a603-159f887d6577",
   "metadata": {},
   "source": [
    "## 验证集构造"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "fa85bcf6-11cc-4a4d-b108-1eefe1b2a66c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:13:36.124577Z",
     "iopub.status.busy": "2022-03-15T07:13:36.124024Z",
     "iopub.status.idle": "2022-03-15T07:13:38.921506Z",
     "shell.execute_reply": "2022-03-15T07:13:38.921078Z",
     "shell.execute_reply.started": "2022-03-15T07:13:36.124526Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_23111/1045791764.py:7: TqdmDeprecationWarning: This function will be removed in tqdm==5.0.0\n",
      "Please use `tqdm.notebook.tqdm` instead of `tqdm.tqdm_notebook`\n",
      "  for idx in tqdm_notebook(range(train_data.shape[0] - 1000, train_data.shape[0] + 1)):\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "113ac4ebbaba4bd7b6fb93bb9e8bacf5",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/1001 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from sentence_transformers import evaluation\n",
    "\n",
    "eval_s1 = []\n",
    "eval_s2 = []\n",
    "eval_socre = []\n",
    "\n",
    "for idx in tqdm_notebook(range(train_data.shape[0] - 1000, train_data.shape[0] + 1)):\n",
    "    eval_s1.append(train_data.loc[idx][\"title\"])\n",
    "    eval_s2.append(corpus_data.loc[qrels.loc[idx].ravel()[0]][\"title\"])\n",
    "    eval_socre += [1]\n",
    "\n",
    "    if idx-1 in train_neg_piar:\n",
    "        for neg_idx in train_neg_piar[idx-1]:\n",
    "            eval_s1.append(train_data.loc[idx][\"title\"])\n",
    "            eval_s2.append(corpus_data.loc[neg_idx][\"title\"])\n",
    "            eval_socre += [0]\n",
    "        \n",
    "    rand_idx = np.random.randint(corpus_data.shape[0], size=10)\n",
    "    for neg_idx in rand_idx:\n",
    "        eval_s1 += [train_data.loc[idx][\"title\"]]\n",
    "        eval_s2 += [corpus_data.loc[neg_idx][\"title\"]]\n",
    "        eval_socre += [0]\n",
    "\n",
    "\n",
    "evaluator = evaluation.EmbeddingSimilarityEvaluator(\n",
    "    eval_s1, eval_s2, eval_socre, write_csv=True\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "e9e6355d-6415-4c32-8486-bb79ad1c8418",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:14:08.930034Z",
     "iopub.status.busy": "2022-03-15T07:14:08.929485Z",
     "iopub.status.idle": "2022-03-15T07:14:08.938250Z",
     "shell.execute_reply": "2022-03-15T07:14:08.937135Z",
     "shell.execute_reply.started": "2022-03-15T07:14:08.929982Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(5, 30, 1)"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "idx = 11\n",
    "len(eval_s1[idx]), len(eval_s2[idx]), eval_socre[idx]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5de2d6a0-6105-40f4-891f-dd9462acfdbb",
   "metadata": {},
   "source": [
    "## sentence-bert"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "4bd039fc-b843-4d49-99e5-260b7181256e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:14:16.927805Z",
     "iopub.status.busy": "2022-03-15T07:14:16.927384Z",
     "iopub.status.idle": "2022-03-15T07:14:28.165577Z",
     "shell.execute_reply": "2022-03-15T07:14:28.164973Z",
     "shell.execute_reply.started": "2022-03-15T07:14:16.927756Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Some weights of the model checkpoint at bert-base-chinese were not used when initializing BertModel: ['cls.predictions.transform.LayerNorm.bias', 'cls.predictions.transform.dense.bias', 'cls.seq_relationship.bias', 'cls.predictions.transform.LayerNorm.weight', 'cls.predictions.bias', 'cls.predictions.decoder.weight', 'cls.seq_relationship.weight', 'cls.predictions.transform.dense.weight']\n",
      "- This IS expected if you are initializing BertModel from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n",
      "- This IS NOT expected if you are initializing BertModel from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\n"
     ]
    }
   ],
   "source": [
    "from sentence_transformers import SentenceTransformer, models, util\n",
    "from torch import nn\n",
    "\n",
    "word_embedding_model = models.Transformer(\"bert-base-chinese\", max_seq_length=50)\n",
    "pooling_model = models.Pooling(word_embedding_model.get_word_embedding_dimension())\n",
    "dense_model = models.Dense(\n",
    "    in_features=pooling_model.get_sentence_embedding_dimension(),\n",
    "    out_features=128,\n",
    "    activation_function=nn.Tanh(),\n",
    ")\n",
    "\n",
    "model = SentenceTransformer(modules=[word_embedding_model, pooling_model, dense_model])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "a1778bf4-9fde-40de-bd21-534a6f4dda3a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:14:45.924384Z",
     "iopub.status.busy": "2022-03-15T07:14:45.924047Z",
     "iopub.status.idle": "2022-03-15T07:19:29.351767Z",
     "shell.execute_reply": "2022-03-15T07:19:29.350783Z",
     "shell.execute_reply.started": "2022-03-15T07:14:45.924349Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/lyz/.local/lib/python3.9/site-packages/transformers/optimization.py:306: FutureWarning: This implementation of AdamW is deprecated and will be removed in a future version. Use thePyTorch implementation torch.optim.AdamW instead, or set `no_deprecation_warning=True` to disable this warning\n",
      "  warnings.warn(\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "a277b8fa67714d978f2591019916179f",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Epoch:   0%|          | 0/2 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "5f1cbb4fc60d40c8a501176b5a77b4b8",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Iteration:   0%|          | 0/210 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "bd877755348f42a8bb3bf6417cc4af83",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Iteration:   0%|          | 0/210 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from sentence_transformers import InputExample, SentenceTransformer, losses\n",
    "\n",
    "# Define your train dataset, the dataloader and the train loss\n",
    "train_dataloader = DataLoader(train_examples, shuffle=True, batch_size=100)\n",
    "train_loss = losses.CosineSimilarityLoss(model)\n",
    "\n",
    "\n",
    "# Tune the model\n",
    "model.fit(\n",
    "    train_objectives=[(train_dataloader, train_loss)],\n",
    "    epochs=2,\n",
    "    warmup_steps=100,\n",
    "    evaluator=evaluator,\n",
    "    evaluation_steps=1000,\n",
    "    show_progress_bar=True,\n",
    "    output_path=\"./\",\n",
    "    checkpoint_save_steps=10000,\n",
    "    save_best_model=True,\n",
    "    checkpoint_path='./'\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "0d36fdd0-ff27-44cd-9e05-e4ab2c4f533b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:20:33.900741Z",
     "iopub.status.busy": "2022-03-15T07:20:33.900322Z",
     "iopub.status.idle": "2022-03-15T07:20:33.907873Z",
     "shell.execute_reply": "2022-03-15T07:20:33.907237Z",
     "shell.execute_reply.started": "2022-03-15T07:20:33.900692Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "20979"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(train_examples)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a03cf5ec-20ff-4a59-add1-45850c82383f",
   "metadata": {},
   "source": [
    "## 验证 & 提交"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "df5caa2d-b890-4ab6-bc9f-71765bb16d88",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:20:51.824520Z",
     "iopub.status.busy": "2022-03-15T07:20:51.824184Z",
     "iopub.status.idle": "2022-03-15T07:20:51.918546Z",
     "shell.execute_reply": "2022-03-15T07:20:51.918009Z",
     "shell.execute_reply.started": "2022-03-15T07:20:51.824492Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "query_len = train_data.shape[0]\n",
    "corpus_len = corpus_data.shape[0]\n",
    "\n",
    "query_len = 1000\n",
    "corpus_len = 10000\n",
    "query_sentences = list(train_data[\"title\"])[:query_len]\n",
    "corpus_sentences = list(corpus_data[\"title\"].iloc[:])[:corpus_len]\n",
    "corpus_sentences = [x for x in corpus_sentences if len(x) > 10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "bf308a33-e8d3-456a-9536-a93ff64e20f0",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:23:31.825048Z",
     "iopub.status.busy": "2022-03-15T07:23:31.824631Z",
     "iopub.status.idle": "2022-03-15T07:23:31.832562Z",
     "shell.execute_reply": "2022-03-15T07:23:31.832144Z",
     "shell.execute_reply.started": "2022-03-15T07:23:31.825000Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "SentenceTransformer(\n",
       "  (0): Transformer({'max_seq_length': 50, 'do_lower_case': False}) with Transformer model: BertModel \n",
       "  (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})\n",
       "  (2): Dense({'in_features': 768, 'out_features': 128, 'bias': True, 'activation_function': 'torch.nn.modules.activation.Tanh'})\n",
       ")"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.eval()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "6650dbeb-06fe-4e2b-8e49-54c7ff31919c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:21:49.827566Z",
     "iopub.status.busy": "2022-03-15T07:21:49.826997Z",
     "iopub.status.idle": "2022-03-15T07:22:00.074864Z",
     "shell.execute_reply": "2022-03-15T07:22:00.074359Z",
     "shell.execute_reply.started": "2022-03-15T07:21:49.827515Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "a23de96b02054a87aeabcf878dc84073",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Batches:   0%|          | 0/2 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "dd3b1556670a4c97b306abc979d88e0e",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Batches:   0%|          | 0/20 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "query_embeddings = model.encode(query_sentences, batch_size=500, show_progress_bar=True)\n",
    "corpus_embeddings = model.encode(corpus_sentences, batch_size=500, show_progress_bar=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "1aae4629-ef8c-442e-8411-8bdedd9532c2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:21:16.029983Z",
     "iopub.status.busy": "2022-03-15T07:21:16.029539Z",
     "iopub.status.idle": "2022-03-15T07:21:16.040999Z",
     "shell.execute_reply": "2022-03-15T07:21:16.039909Z",
     "shell.execute_reply.started": "2022-03-15T07:21:16.029933Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import normalize\n",
    "\n",
    "query_embeddings = normalize(query_embeddings)\n",
    "corpus_embeddings = normalize(corpus_embeddings)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "e72f3336-9686-4387-a18f-1e2e67a6cc11",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:23:38.959950Z",
     "iopub.status.busy": "2022-03-15T07:23:38.959525Z",
     "iopub.status.idle": "2022-03-15T07:23:38.966480Z",
     "shell.execute_reply": "2022-03-15T07:23:38.965930Z",
     "shell.execute_reply.started": "2022-03-15T07:23:38.959902Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1000, 128)"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "query_embeddings.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "f875e6c3-7c56-4fc8-814d-dd6f0e0c5a51",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:23:39.828963Z",
     "iopub.status.busy": "2022-03-15T07:23:39.828544Z",
     "iopub.status.idle": "2022-03-15T07:23:39.845507Z",
     "shell.execute_reply": "2022-03-15T07:23:39.844989Z",
     "shell.execute_reply.started": "2022-03-15T07:23:39.828914Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "cos_sim = util.cos_sim(query_embeddings, corpus_embeddings)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "10d9c2fa-7742-4144-b6de-5d0410fd118a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T07:23:40.909429Z",
     "iopub.status.busy": "2022-03-15T07:23:40.908894Z",
     "iopub.status.idle": "2022-03-15T07:23:41.134186Z",
     "shell.execute_reply": "2022-03-15T07:23:41.133719Z",
     "shell.execute_reply.started": "2022-03-15T07:23:40.909372Z"
    },
    "scrolled": true,
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "美赞臣亲舒一段 \t 原装 HP DL388 GEN8 服务器RAID卡1G缓存带电池    633542-001 \t 领券满减】美赞臣安婴儿A+亲舒 婴儿奶粉1段850克 0-12个月宝宝\n",
      "tensor(0.6575)\n",
      "慱朗手动料理机 \t P棉蓄温毯子户外保温热反射毯子地垫被子露营出差车载家用沙发毯 \t Braun/博朗 MQ3035/3000/5025料理棒手持小型婴儿辅食家用搅拌机\n",
      "tensor(0.6544)\n",
      "電力貓 \t 男女个性潮款钛钢无耳洞耳骨夹日韩欧美流行女士耳骨夹潮男耳骨夹 \t 小米WiFi电力猫无线路由器套装一对300M穿墙宝家用信号增强扩展器\n",
      "tensor(0.4757)\n",
      "掏夹缝工具 \t 南卡巡更棒电子巡更系统4G网络巡更棒打点器巡逻棒巡更机巡检仪 \t 电梯地坎清洁工具除灰尘神器轿厢门槽缝隙掏勺维保打扫奥的斯三菱\n",
      "tensor(0.6929)\n",
      "飞推vip \t 【正版现货】纺织高职高专规划教材:纺织品检验 田恬 纺织品检验基础知识 纺织纤维鉴别 纱线质量的检验 色差评定书籍 服装质量检 \t 飞逗推拍 店主邀请码 去水印 创意视频一键制作视频\n",
      "tensor(0.5147)\n",
      "多功能托地把 \t 微星 GE75 GP75 GL75 MS-17E1 17E2 17E3 17E5 A壳B壳C壳D壳 屏轴 \t 免手洗拖把家用一拖净刮刮乐干湿两用懒人拖平板墩布托帕拖地神器\n",
      "tensor(0.5571)\n",
      "充气浮力袖 \t 湖北腊鱼风干鱼块湖南特产咸鱼干货水产腌鱼块武汉腊鱼非烟熏500g \t 学游泳神器装备充气腰背漂水袖浮臂三角浮力儿童游泳辅助工具大人\n",
      "tensor(0.7045)\n",
      "盒马花胶鸡汤锅 \t 茶色超轻近视眼镜框女可配防蓝光有度数镜片韩版圆脸显瘦眼睛架潮 \t 盒马鲜生工坊代购 花胶奶冻150g 入口Q弹 奶味浓郁 香甜丝滑\n",
      "tensor(0.6574)\n",
      "塞塞乐 \t 验钞灯手电筒儿童小迷你电池三色便携紫光微小型激光红外线钥匙扣 \t 婴儿童玩具6个月以上8宝宝益智早教0一1岁男孩女孩六9月十7新生礼\n",
      "tensor(0.4963)\n",
      "广汽传祺gs5挡风遮雨条子 \t 韩国东大门虎年本命年手链女招财转运珠红色手串手饰品送闺蜜礼物 \t 2021款广汽传祺GS5晴雨挡遮雨板传奇GS5配件车窗雨眉防雨条挡雨板\n",
      "tensor(0.8650)\n",
      "冰墩敦人偶服装 \t 立顿茉莉花茶包独立纸包装袋泡茶酒店客房奶茶店专用茶包80袋包邮 \t 灯笼布偶熊猫道具服装吉祥物人穿玩偶宣传传单服活动人偶服装\n",
      "tensor(0.6734)\n",
      "寵物罐頭密封蓋 \t 韩国夹子头饰流苏抓夹后脑勺气质毛球半扎发发夹少女发抓毛绒发卡 \t 仁可宠物 猫罐头保鲜盒密封盖防潮可加热猫咪罐头勺喂食勺猫用品\n",
      "tensor(0.6504)\n",
      "15 蒸汽爱美克闸阀 \t 苏苏姐家云絮毛线团钩针棒针手工DIY毛衣围巾宝宝玩偶小物编织 \t 埃美柯 8135闸阀304不锈钢蒸汽用闸阀中型Z15W-16P耐温腐蚀4分6分\n",
      "tensor(0.7181)\n",
      "电动切面机 \t 居家室内防滑手工毛线轮胎拖鞋泡沫车轮长毛绒面橡胶牛筋鞋底包邮 \t 复兴牌面条机电动家用不锈钢压面机多功能半全自动四种面条DMT-6\n",
      "tensor(0.7210)\n",
      "医用震动排痰机 \t 荟萃楼黄金项链女999足金o字链细款金链子锁骨链素链配链纯金女款 \t 普门排痰机振动背心式慢阻肺支气管扩张肺气肿医用咳痰祛痰神器\n",
      "tensor(0.5427)\n",
      "草莓盆专用夹 \t XINPOR户外运动水袋清洁刷晾干架水管水嘴清洁刷四件套水瓶清洗刷 \t 大棚草莓钩盆器新款农具草莓采摘神器摘取自如温室水果铁丝钩子\n",
      "tensor(0.6169)\n",
      "lg洗烘套装 \t 妈妈冬装亮面免洗羽绒服40岁年轻女士保暖连帽外套中老年时尚棉衣 \t LG RC90V9AV2W RC90V9JV2W RH10进口9/10KG热泵双变频干衣烘干机\n",
      "tensor(0.6584)\n",
      "芝士脆 \t 定制中式仿古大门拉手 黑色玻璃木门大把手 LOGO古铜长条形大扶手 \t 山居小食 芝士小脆棒 香酥小零食 罐装 110g包邮\n",
      "tensor(0.7261)\n",
      "笔记本应用书籍 \t CF 穿越火线 活动 代抽 \t ThinkPad笔记本电脑应用技术精粹\n",
      "tensor(0.8147)\n",
      "来旺兄弟 \t 美式笔件圆珠笔高品质制笔套件配件DIY做笔易乐木艺木工材料包艾 \t 宠物电吹风机洗澡吹毛神器速干狗狗猫咪洗澡吹风拉毛一体机烘干\n",
      "tensor(0.4617)\n",
      "深圳断桥铝门窗 \t 月芽儿骑士靴女冬季新款低跟百搭不过膝靴子后拉链网红长筒靴 \t 深圳富贵花断桥铝合金门窗户封阳台定制落地隔音钢化玻璃窗推拉窗\n",
      "tensor(0.8105)\n",
      "自亮灯 \t 100贴发热生姜贴腰间盘突出膏药贴疼痛专用颈椎病肩周炎腰腿疼痛 \t USB充电灯泡停电应急照明灯家用式移动超亮户外led夜市摆摊地摊灯\n",
      "tensor(0.7305)\n",
      "green superfood \t 【TianC 陈赫】2021新款夏季拼接黑色休闲裤男潮流薄款束脚裤长裤 \t Amazing Grass爱美草膳食有机果蔬精粹粉 罐装210g/罐果蔬粉综合\n",
      "tensor(0.5751)\n",
      "直龙爪 \t blythe小布娃衣 插肩卫衣套 OB24/azone6分素体可穿【不含娃娃】 \t 工匠大师worker 软弹枪玩具海绵弹短弹10发龙爪弹夹弹夹井斜龙爪\n",
      "tensor(0.4906)\n",
      "儿童罗马凉鞋 \t 海康威视户外室外防水音柱有源喇叭音箱音响广播喇叭工地自动播放 \t 女童镂空包头凉鞋2021新款夏季时尚公主鞋女孩中大童软底时装童鞋\n",
      "tensor(0.7815)\n",
      "沪尚茗居 \t CAT秋冬男鞋卡特高帮固特异牛皮马丁靴男短靴工装靴手工户外皮鞋 \t 上海卫生间装修服务局部改造旧房翻新老房拆旧干湿分离防水处理\n",
      "tensor(0.5893)\n",
      "三点式内衣 托 \t 水泥罐车配件链条卡子大滚珠链条管卡喉箍散装罐车配件链条卡子 \t 情趣内衣性感刺绣镂空文胸钢托三点式透明激情套装午夜诱惑骚\n",
      "tensor(0.6446)\n",
      "imblu \t 蓝光水钻美少女华为nova4手机壳3i硅胶p40pro+卡通20i可爱女款nova4e腕带支架20青春版潮牌畅享10/plus水冰月 \t 5折 清仓特卖 内衣包 多用袋 衣物袋 洗漱包 手拿包\n",
      "tensor(0.5193)\n",
      "海之蓝数码港 \t 简约笑脸适用iphone13promax苹果12手机壳11全包xr/xs软硅胶78p女 \t Hasee/神舟 战神 Z7T-TA5NS/I5-11400H/16G/512G/RTX3050Ti笔记本\n",
      "tensor(0.4943)\n",
      "奶羊母 \t ins网状吊床秋千北欧风咖啡屋室内室外民宿抖音吊篮懒人椅子吊椅 \t 奶山羊活体母羊奶山羊活羊羊羔萨能奶山羊纯种奶羊崽一对奶羊养殖\n",
      "tensor(0.5933)\n",
      "峡谷宝典 \t 飞利浦数显剃光头神器自刮刮胡刀五刀头水洗多功能电动剃须刀机子 \t LOL英雄联盟手游点劵皮肤  825点券倍数冲值 皮肤790 990国服\n",
      "tensor(0.4621)\n",
      "nn2813六针机芯 \t 欧式风格别墅实景图片案例复试挑空室内装修设计参考高端奢华效果 \t 手表配件 国产2813六针单历机芯 国产8205 8215六针单历机机械\n",
      "tensor(0.7284)\n",
      "纯竹青竹筐 \t butterfly造型发胶海马体发廊定型喷雾蓬松男女蝶伊清影干胶清香 \t 碳篓竹青编织篮菜篮子水果篮竹筐馒头筐平底篮竹篓竹制品环保纯\n",
      "tensor(0.7611)\n",
      "凯基木油色精 \t vivoS5钢化膜防窥S5全屏覆盖防偷窥手机膜vivo新品防窥膜vovos5全包防摔vivis5高清玻璃防指纹隐私保护膜贴膜 \t 凯基耐候木油通用性色浆/木蜡油多颜色卡/防腐油性环保\n",
      "tensor(0.7008)\n",
      "张泽禹小卡 \t 梳子男士排骨梳大背头造型梳子卷发梳子家用理发店专业吹发型内扣 \t 不是正TF家族少年进化论迷宫小卡朱志鑫 邓佳鑫 张极 左航\n",
      "tensor(0.5648)\n",
      "吹气尘枪美特 \t 设计感黑白条纹慵懒风圆领针织衫休闲百搭宽松毛衣秋冬显瘦上衣女 \t 美特吹尘枪气动高压尘吹枪工具 除尘枪吹灰枪清洁喷枪套装吹风枪\n",
      "tensor(0.6276)\n",
      "爱上历史宋朝历史的惊鸿一瞥 \t 罐头猫咪小零食整箱湿粮主食成幼猫用品补充营养增肥金枪鱼鸡胸肉 \t 新华正版 文盛武衰宋朝历史一瞥爱上历史丛书 徐洪兴姚荣涛葛剑雄李 历史 中国史 广东人民 人天兀鲁思（北京）媒 图书籍\n",
      "tensor(0.6484)\n",
      "口代装，沙田柚 \t 浩然2店邮费链接圆通珠宝奇石其他原石原石缅甸手镯原石毛料翡翠 \t 柚子开果器独立包装多功能蜜柚剥皮刀开沙田柚刀剥柚子皮神器家用\n",
      "tensor(0.6425)\n",
      "小蔡胡颗粒 \t 得力多功能可爱文具盒儿童三层大容量铅笔盒韩版小清新卡通皮卡丘笔袋ins小学生幼儿园男女孩用笔盒1-3-5年级 \t 白云山 小柴胡颗粒 10g*6袋/盒\n",
      "tensor(0.6762)\n",
      "声波洗鼻鼻窦 \t 上海现货台湾云林口湖优质乌鱼子乌鱼籽100克即食装 \t 美国塞诺松声波鼻通仪家用鼻塞神器鼻窦成人儿童孕妇\n",
      "tensor(0.7521)\n",
      "绿松石碎料 \t 九芝堂 裸花紫珠片 0.5g*24片/盒 清热解毒血热毒盛所致的呼吸道消化道出血及细菌感染性炎症收敛止血药房同款旗舰店正品口服片剂 \t 矿区天然原矿绿松石毛石碎片镶嵌供佛曼扎练手边角料圆珠diy文玩\n",
      "tensor(0.5649)\n",
      "179俱乐部 \t 男童毛衣背心女童针织衫马甲双层加厚宝宝坎肩保暖打底衫秋冬新款 \t 泰斯卡10年单一麦芽苏格兰威士忌 洋酒 TALISKER SINGLE MALT正品\n",
      "tensor(0.4455)\n",
      "木盒子长方形 \t 虎头式紧线器10寸紧线钳12寸拉线器8寸大棚葡萄架铁丝钢丝拉紧器 \t 木盒定做长方形佛珠收纳盒办公室杂物整理盒创意储物盒桌面收纳盒\n",
      "tensor(0.5137)\n",
      "室内运动 \t 新s品硅胶氩气管氩弧焊机气管氩气软管氩气瓶连接管氩气表专用气 \t 无绳跳绳球儿童幼儿园初学3岁宝宝5大班专用绳子训练器小学生神器\n",
      "tensor(0.6442)\n",
      "酷威机盖隔音板 \t 针织衫新款2021爆款时尚洋气短款薄款初秋早秋设计感小香风打底衫 \t 道奇 酷威机盖隔音棉 隔热棉 酷威引擎盖隔音棉 道奇酷威机盖棉\n",
      "tensor(0.6080)\n",
      "高爾夫馬克 \t 软件定制app开发定制微信 开发微信网站APP开发app 定制开发 \t 高尔夫球帽夹 PXG Mark马克golf 日本夹子带磁铁球位置标一件包邮\n",
      "tensor(0.4943)\n",
      "鱼肉卷 \t 北汽绅宝14-16款D50发动机右固定支架机脚垫 改良款带油压 \t 包心鱼卷火锅丸子小包装冷冻散装日式关东煮食材711夹心鱼丸家用\n",
      "tensor(0.7589)\n",
      "淘小秋生活馆 \t 大码女装2021秋冬新款胖妹妹时尚设计感小众减龄别致格子上衣外套 \t 小王子玫瑰花星球灯装饰氛围灯摆件夜灯联名珍藏版周边生日礼物\n",
      "tensor(0.4458)\n",
      "牙盒乳牙 \t 脚链女夏红绳情侣2021新款潮高级女可调节本命年编织脚绳夏季配饰 \t 超可爱粉色天使翅膀儿童乳牙盒宝宝脱牙收藏保存纪念屋夹子胎毛瓶\n",
      "tensor(0.7402)\n",
      "电子标签5.65配件 \t 一条过冬儿童棉裤刺绣拉条长裤加绒加厚冬装中大童休闲夹棉保暖裤 \t 电子桌牌会议名牌智能席卡七彩电子墨水屏双面屏显示无纸化会议牌贵宾牌WiFi桌签台卡可定制步频PM835\n",
      "tensor(0.5561)\n",
      "马桶紫外线消毒灯 \t 耐克正品女裤2021年春季新款运动休闲速干梭织束脚长裤CJ7347-010 \t 美丽箭品牌马桶消毒器杀菌器坐便器智能感应全自动紫外线除菌器\n",
      "tensor(0.5701)\n",
      "木头书橱 \t 适用于悦动伊兰特途胜朗动英文后字母标贴标全车标汽车标志配件 \t 中式书架置物架简易小书柜实木收纳架摆件架子简约现代落地储物柜\n",
      "tensor(0.7624)\n",
      "森冈希世子 \t 校花的贴身高手游爆衣养成卡牌无限版游戏折扣后台GM安卓i os苹果 \t 【一物】日本 森岡希世子 手作 白瓷 透光 餐具 杯 钵 碗 现货\n",
      "tensor(0.3656)\n",
      "渔翁与海 \t 天猫6孕贝婴儿食物咬咬袋果蔬乐牙胶磨牙棒吃水果辅食器 颜色随机 \t 新鲜黄花鱼东海海鲜水产鲜活冷冻商用深海宁德大黄鱼小黄鱼生鲜\n",
      "tensor(0.6088)\n",
      "barsone \t 九阳电压力锅配件排气阀JYY-20M1/60C1/40YS25/50YS30限压阀重锤 \t 朋森可折叠泡脚桶家用小型加热恒温电动足浴盆全自动足浴洗脚神器\n",
      "tensor(0.4997)\n",
      "中州药膏 \t 适用华为畅享20pro钢化膜畅想9plus全屏10覆盖20e9e10e防蓝光se护眼8防摔Z无白边5g贴膜适用por水凝9s手机膜 \t 中州氧化锌升华硫软膏20g痤疮酒渣鼻脂溢性皮炎\n",
      "tensor(0.7860)\n",
      "花木支架铁杆 \t 美国海军peacoat外套羊毛呢子藏青修身男式翻领冬双排扣740大衣 \t 林木箍树组合撑架树架q抱大移植支撑树支撑架铁杆桩树木养护卡扣\n",
      "tensor(0.6790)\n",
      "润谷芝时 \t 日本购灯笼七彩户外纸彩灯室内结婚饭店字福D红仿古塑料灯笼小挂 \t 现磨养胃无糖芝麻糊养发生发老年人产妇孕妇儿童一全家人粗粮粉\n",
      "tensor(0.6514)\n",
      "衔铁马术 \t HPBJ工装羽绒服2022新款潮流短款加厚保暖休闲连帽白鸭绒情侣外套 \t 英式佩勒姆口衔铁 不锈钢马嚼子 橡胶嘴吹马衔铁西部巨人马具马术\n",
      "tensor(0.5689)\n",
      "富安娜电热毯 \t 丝绒小黑裙 侧开叉半月袖黑色丝绒改良旗袍裙时尚小黑裙多色可选 \t 双人电热毯家用速热双温双控保暖安全单人学生宿舍专用电褥子普通\n",
      "tensor(0.7817)\n",
      "装饰云 \t 日本斑马复古笔系列jj15中性笔新五色限定款酒红色SARASA按动水笔0.5黑笔替芯斑马旗舰店官网zebra斑马牌日系 \t 棉花白色云朵连接简约装饰派对团漂浮求婚实用仿真道具吊顶白云\n",
      "tensor(0.4638)\n",
      "不绣钢外墙帽 \t 台达PLC的温控器变频器伺服步进视频教程 从入门到精通 \t 加厚304不锈钢风口管帽风帽管罩防雨烟罩外墙排风口出气口新风口\n",
      "tensor(0.6296)\n",
      "金一黄金红包 \t KADAIYA stylenanda   冬季暖暖系列 翻领撞色羊羔毛外套 \t 【新年礼物】金一 KINGEE玩偶奇兵红包金币足金章送礼压岁钱\n",
      "tensor(0.5732)\n",
      "酒店客房服务指南2021 \t 南方酒店客房服务车布草袋房口清洁车带分隔栏手推工作车静音车轮 \t 酒店皮具套装定制批发印logo服务指南遥控器收纳纸巾盒阻燃垃圾桶\n",
      "tensor(0.5432)\n",
      "毛刷子工业用 \t 【现货】乐高 LEGO 212007 超级英雄 冰冻人 sh621 含武器 稀有 \t 工业毛刷条清洁机械软毛尼龙丝防尘密封毛刷条铝合金条刷子f H型\n",
      "tensor(0.6722)\n",
      "乐扣饭袋 \t 琪加304不锈钢保温饭盒3多层2双层1儿童小学生成人分层手提便当盒 \t 乐扣乐扣保温便当包饭盒袋子带饭午餐铝箔保温防水上班族手提加厚\n",
      "tensor(0.7072)\n",
      "羅技音響 \t 穿戴阳具空心 男用阴茎套仿真震动遥控超大号内裤式皮裤成人用品 \t 【官方旗舰店】罗技Z906音箱5.1环绕声家庭影院THX认证罗技音箱\n",
      "tensor(0.6820)\n",
      "u盘wifi \t 岩板新中式实木电视柜茶几家用客厅组合禅意简约小户型中国风地柜 \t 小米360随身WiFi 免费插在电脑上的u盘式无线路由器 手机用的waif\n",
      "tensor(0.6140)\n",
      "闪艺破解 \t 人体感应灯衣柜楼道橱柜玄关洗手间电池USB充电LED灯条光控小夜灯 \t 闪艺账号出租\n",
      "tensor(0.4871)\n",
      "泡水车 \t 篮球场集装箱休息室 旧集装箱改造办公室 多个集装箱组合上门搭建 \t 东风大型消防车森林灭火应急救援5吨8方10吨小型泡沫消防洒水车\n",
      "tensor(0.5860)\n",
      "爸爸本命年红色衣服 \t 礼物盒大号精美口红盒子七夕礼盒包装盒化妆品女生生日礼品盒空盒 \t 羊绒衫男100纯羊绒马甲背心坎肩加厚拉链半高领爸爸装高端针织衫\n",
      "tensor(0.5052)\n",
      "小镜子 \t 2022国考省考公考云飞扬齐麟满分计划视频行测数量逻辑判断网课 \t 梳妆台桌面化妆镜女 台式木质小号家用单面镜 学生宿舍卧室梳妆镜\n",
      "tensor(0.5929)\n",
      "五菱星辰 \t 【Saliya&middot;相逢为圆】珍珠开口戒指女麻花圈双珠高级感指环纯银新 \t 五菱宏光MINI星辰宏光S3凯捷征程荣光之光后视镜雨眉倒车镜挡雨板\n",
      "tensor(0.6960)\n",
      "mov860-40防雷模块 \t 欧洲站高帮鞋女2021年新款欧货潮酷ins老爹鞋真皮拼色厚底休闲鞋 \t 一级浪涌保护器防雷器4P2P二级模块低压电器40KV60KV100KV\n",
      "tensor(0.6314)\n",
      "喜鹊活鸟体 \t 秋冬季半高领毛衣男ins潮流网红痞帅线衣宽松港风复古休闲针织衫 \t 十姐妹鸟活体保姆鸟种鸟活文鸟珍珠鸟宠物鸟观赏鸟成年说话鸟繁殖\n",
      "tensor(0.6245)\n",
      "月红粉 \t 汉雷长城欧拉R1黑猫氙气大灯欧拉R2白猫超亮氙气灯专用疝气灯改装 \t 花喜官网正品酵素植物高纤果蔬酵素粉孝素官方授权抗糖顺丰\n",
      "tensor(0.5198)\n",
      "sos唇贴 \t 网红韩国欧尼同款芒果靴方头短靴女2021秋冬新款百搭平底显瘦单靴 \t 现货 德国原装进口SOS嘴唇嘴圈疱*疹贴上火小水泡\n",
      "tensor(0.7509)\n",
      "瓶盖开启器 \t 正方形超大五格打包盒1500m外卖盒一次性快餐盒加厚透明5格 200套 \t 开瓶盖神器护士家用儿童多用途工具开盖器铝盖口服液开瓶器起子新\n",
      "tensor(0.5514)\n",
      "碳炉子煮茶 \t 武汉一美 国产瘦腿/瘦肩200单位 塑造纤细美腿 瘦小腿肌肉 \t 九土日式手工陶泥炭炉橄榄碳炉小火炉复古煮茶炉茶道禅意风炉泥炉\n",
      "tensor(0.7427)\n",
      "小樣自熱米飯 \t 挂墙式洗手盆柜组合小户型卫生间陶瓷洗脸盆北欧台上盆简易洗漱台 \t 6桶装小样自热米饭煲仔饭桶装即食宵夜方便速食食品懒人宿舍\n",
      "tensor(0.7514)\n",
      "墙面自喷漆 \t 太平鸟女装官方旗舰店两件套网纱衬衫女2022春款衬衣法式寸衫上衣 \t 外墙漆乳胶漆防水防晒专用涂料室外家用自刷耐用面漆户外彩色油漆\n",
      "tensor(0.8617)\n",
      "和泉fc6a一j4a1 \t 电动车脚踏垫摩托车脚垫通用雅迪爱玛电动电瓶车垫子脚垫防水自剪 \t FC6A-J4A1【4PT VOLTAGE CURRENT INPUT MOD】\n",
      "tensor(0.6067)\n",
      "依格空呼面罩 \t 渐变灰医用外科一次性医疗口罩三层夏季透气独立包装防飞沫粉尘ZC \t 正压式空气呼吸器面具法式接口空呼配件消防空呼面罩全面喷漆防毒\n",
      "tensor(0.6733)\n",
      "厂牌壳 \t 【主播推荐】棒棒娃高原亚可风干牛肉干手撕牛肉超干小吃零食108g \t 公交卡套创意搞怪个性饭卡装卡的卡套透明厂牌卡套挂脖保护套硬壳\n",
      "tensor(0.6366)\n",
      "花鼓弹片 \t 包邮 原装正品 惠普 HP 6910 6910P  笔记本键盘 带指点 us \t 塔裕 RT三爪 五爪 六爪久基花鼓齿1工具千金片 卡簧 8 9 圈0 11速\n",
      "tensor(0.7020)\n",
      "蜜儿港奶瓶配件 \t 中年妈妈貂绒连衣裙女秋冬2021新款高端时尚洋气减龄优雅气质裙子 \t 配亲多Kub可优比dicobell蜜儿港dexbaby小土豆水杯吸嘴吸管杯配件\n",
      "tensor(0.8246)\n",
      "男童包包 \t 可配近视眼镜女有度数学生超轻眼镜框ins风网红平光镜圆脸显瘦男 \t 男孩子斜挎包2022新款洋气户外儿童斜肩包时尚棋盘格春款女童胸包\n",
      "tensor(0.5441)\n",
      "为人民服务围裙 \t ff14装修工具人  装修工接装修 支持国际服 \t LMINGHOME品牌围裙餐厅茶室酒店店员工作服五星雷锋家居创意包邮\n",
      "tensor(0.5204)\n",
      "水母流星雨烟火 \t 放大镜鉴定40倍维修烟酒折叠印刷带灯织物经纬密度镜照布文玩鸽眼 \t 婚庆道具幻彩水母装饰海洋主题风格道具商场中庭酒店大堂创意布置\n",
      "tensor(0.5769)\n",
      "机用红色麻将46 \t 热风专柜正品真皮大头面包鞋女加绒百搭丑萌小白鞋2021秋冬松糕厚 \t 新品卡通麻将樱桃小丸子大红喜庆 家用手搓机打网红可爱麻雀牌\n",
      "tensor(0.8508)\n",
      "笔记本电脑硬盘二手 \t 适用 比亚乔 BOSS CIAO 50cc 65cc 霸伏 套缸 气缸总成 中缸总成 \t 原装 Dell/戴尔 ST300MM0006 300G 2.5 10K SAS 服务硬盘  0PGHJG\n",
      "tensor(0.7859)\n",
      "kipper一家 \t 八角袋 景津压滤机滤布 耐酸碱 化工农药 \t 牛津树阅读典范英语人物玩偶白坯木头人偶儿童diy涂鸦关节小木偶\n",
      "tensor(0.3451)\n",
      "吸尘器干湿两用家用 \t 峨眉雪芽春喻睿100g春茶高山毛峰绿茶茶叶四川特产 \t 【新品】BISSELL必胜布艺沙发清洗机喷抽吸一体地毯窗帘清洁机\n",
      "tensor(0.8677)\n",
      "袁大头外框挂件 \t 玻璃酒精灯加热加厚防爆150 250ml含灯芯灯帽三脚架不锈钢酒精灯 \t 银饰袁大头银元吊坠 银元吊坠边框  S925纯银龙头银圈 大洋币圈\n",
      "tensor(0.5971)\n",
      "voda工业​ \t 亮朵化妆包女便携大容量超大新款超火高级双层收纳袋洗漱包品盒 \t VODA原产SPOSN SSO阿尔金盔罩\n",
      "tensor(0.4781)\n",
      "奥利奥玫瑰葡萄 \t 德高美缝剂炫彩美瓷胶墙地暖瓷砖防水防霉勾填缝正品环保真美瓷胶 \t 亿滋奥利奥原味巧克力薄脆巧轻脆夹心小饼干冰淇淋官方旗舰店官网\n",
      "tensor(0.7072)\n",
      "菜刀菜板剪刀 \t 随爱乳头保护罩乳头贴防咬乳头保护器亲密接触型乳盾辅助奶头喂奶 \t 砧板剪刀切菜剪子剪刀剪菜神器多功能切菜神器多用剪刀剪菜剪子\n",
      "tensor(0.7824)\n",
      "梅菜干 \t 迈拓KM穿越者切换器MT-KD02 两台电脑共用键鼠 USB智能文件对拷 \t 盛盛耳梅干菜100g梅干菜扣肉特产干货霉菜无沙\n",
      "tensor(0.7566)\n",
      "异烟肼片包邮 \t 【直降30元】三草两木养卸合一珍萃卸妆油 2ml*30卸妆面部温和 \t 太极 异烟肼片 100mg*100片*1瓶/盒 咳嗽咳痰结核病 用于对异烟肼敏感的各型结核病治疗\n",
      "tensor(0.7269)\n",
      "康丽健舞毯 \t 厨房橱柜门全屋定制门板全铝合金灶台门自装柜门衣柜门平开门定做 \t 康丽中文高清单人跳舞毯电脑加厚支持下载运动减肥跑步跳舞机家用\n",
      "tensor(0.6397)\n",
      "四眼波罗发动机出水管 \t 服饵辟谷 辟谷丹 辟谷丸 辟谷 代餐 断食 秕谷丸 避谷  秕谷 \t 大众老款四眼POLO波罗1.4 1.6 水箱上下水管发动机水管  正品\n",
      "tensor(0.7442)\n",
      "宝马e53 4.6is大修包 \t 如故小衫气质百搭弹力芭蕾小披肩开衫防晒外套特价处理中 \t 适用宝马 E36 E46 E39 E53 老款X5 525 530 325 330 发动机大修包\n",
      "tensor(0.7327)\n",
      "毛笔架笔挂 \t 亮俊可爱白兔塑料手提袋烘焙甜品外卖打包袋沙拉轻食轻食袋文具饰 \t 铜笔架山笔搁黄铜镇尺镇纸毛笔架笔搁笔置笔山摆件\n",
      "tensor(0.7604)\n",
      "仙津豆奶 \t 日本国誉烧饼包PAN CASE条绒笔袋多功能日式kokuyo学生文具收纳包 \t 皮皮岛瓶装豆奶整箱豆奶食品全豆豆奶330ml*24瓶早餐奶植物蛋白\n",
      "tensor(0.7620)\n",
      "xs瑕疵屏 \t [现货]SEGA世嘉 初音未来 MLKU热带盛夏 泰国应援 景品 手办摆件 \t 苹果xsMax原装拆机瑕疵屏幕实拍原装拆机总成xsmax触摸灵敏\n",
      "tensor(0.7731)\n",
      "气缸一体橡胶dk活塞26一8一l2 \t applepencil笔尖套pencil保护套苹果笔套ipencil二代类纸膜一静音 \t 费斯托FESTO气缸整体活塞密封件DK TDP型印刷机密封圈优质\n",
      "tensor(0.8680)\n",
      "磨砂笔盒透明 \t 北欧ins风绿色条纹大理几何抱枕靠垫办公室午睡汽车沙发卧室抱枕 \t diy文具盒材料包自制手工制作奶油胶套装学生创意可爱网红多功能\n",
      "tensor(0.7203)\n",
      "吸管奶嘴 \t 2021春秋季新款格子长袖衬衫男休闲痞帅衬衣男外套上衣服韩版潮流 \t 好孩子婴儿宽口径奶瓶吸管配件E80053通配宽口奶瓶儿童硅胶吸管\n",
      "tensor(0.7363)\n",
      "每天100道口算题卡二年级上 \t icebreaker 美丽诺羊毛 男女通用Mogul冷帽 滑雪美利奴巴拉克拉法 \t 2021版小学二年级口算题卡人教版每天100道20以内加减法混合运算\n",
      "tensor(0.9188)\n",
      "livinginc \t 工匠大师worker 软弹枪玩具海绵弹短弹10发龙爪弹夹弹夹井斜龙爪 \t LIVING inc. 轻奢丝绒窗帘 蓝灰系列 纯色遮光窗帘客厅卧室遮光布\n",
      "tensor(0.4000)\n",
      "漏尿巾 \t 红色小碎花适用苹果11pro手机壳iPhonexsmax新年xr本命年xsxmax菱形小红花朵日韩新款直边硅胶软壳创意十一女 \t poise蓓姿吸水呵护巾240mm成人漏尿护垫孕产妇女性卫生巾纸尿片\n",
      "tensor(0.6920)\n",
      "正北牌方糖 \t 公牛世家男鞋秋冬季老爹鞋ins爆款网红增高跑步运动休闲防滑潮鞋 \t 正北葡萄糖方糖100g*3盒装酸甜味血糖能量块独立小包装\n",
      "tensor(0.7585)\n",
      "勺子夹子 \t matoikumo日本慕伊之梦纸尿裤绚薄系列纸尿裤超薄透气宝宝拉拉裤 \t 北欧金色咖啡勺创意不锈钢封口夹勺茶叶燕麦零食封口咖啡量勺带夹\n",
      "tensor(0.7893)\n",
      "蓝梅轻宜 \t 秋冬情侣装卫衣约会大作战圆领时崎狂三印象拼色鸢一折纸男女外套 \t 【官网正品】轻宜蓝轻畅蓝莓压片糖果新品升级版促销包邮清\n",
      "tensor(0.5694)\n",
      "铅材质衣柜 \t 影楼化妆师专用粉扑大号粉底液干湿两用不吃粉海绵气垫化妆工具 \t 尚百年全铝家具全屋定制衣柜铝合金现代简约平开门铝制家居具衣柜\n",
      "tensor(0.6465)\n",
      "会嵇山 \t 雾霾蓝简约现代雪尼尔窗帘日式轻奢高档大气卧室ins风客厅丝绒布 \t 会稽山绍兴黄酒纯正五年花雕酒500ml*8瓶装整箱半干型加饭酒5年陈\n",
      "tensor(0.5031)\n",
      "补头顶真发递针 \t 2021年春秋新款儿童帆布鞋宝宝布鞋软底男童鞋子幼儿园女小童板鞋 \t 假发片女头顶补发遮白发增发量中老年妈妈夏季全真发轻薄自然发块\n",
      "tensor(0.7735)\n",
      "黄油储存盒 \t 白色小清新蕾丝桌布ins风方桌餐桌布台布法式美式透明盖巾波点纱 \t 日本进口黄油收纳盒涂抹棒直立黄油涂抹器小块黄油存储盒纳豆同款\n",
      "tensor(0.4888)\n",
      "刻刀片 \t 海尔冰箱变频驱动板控制板801-0-5334-229-00-3 4-2269-600-69- \t 303 606 909雕刻美工笔刀小刀片补充替换刀片 12片装2筒\n",
      "tensor(0.7976)\n",
      "7-zip \t 专柜正品哥弟新款代购2021秋冬高腰小脚铅笔裤女1100045 \t 自动发货7 Zip 解压软件 支持32 64位windows系统 中文版带教程\n",
      "tensor(0.5605)\n",
      "苏宁易购炯小炯 \t 韩版婴儿衣服秋冬装夹棉连体衣女宝超洋气碎花棉服哈衣冬季外出服 \t 郭晶晶同款炯小炯蒸汽眼罩睡眠遮光办公室旅行午休缓解眼疲劳1439\n",
      "tensor(0.4691)\n",
      "新雅精品 \t 奇美高音德式G竖笛乐器初学入门6孔8孔C调小学生儿童六孔八孔笛子 \t 新雅半成品方便菜家宴提货券年夜饭熟食套餐年货礼盒江浙沪皖配送\n",
      "tensor(0.5090)\n",
      "扡把夹子 \t 微星 GE75 GP75 GL75 MS-17E1 17E2 17E3 17E5 A壳B壳C壳D壳 屏轴 \t 夹拖把挂钩扫把拖布架强力粘钩浴室阳台卫生间墙壁收纳神器免打孔\n",
      "tensor(0.5976)\n",
      "手推绣机器 \t 茗思黑色连衣裙女2021年秋季新款气质系带蕾丝拼色优雅显瘦假两件 \t 美佳牌GI5-1多功能绣花机(机头) 手推绣绣花机 重机271款机械绣花\n",
      "tensor(0.6998)\n",
      "哈士蟆 \t 宠物貂安格鲁雪貂小水獭宠物活物活体安德鲁花貂活幼崽水貂安哥鲁 \t 东北林蛙 蛤蟆 长白山特产雪蛤 林蛙活体鲜活母豹子14-15只/斤\n",
      "tensor(0.6436)\n",
      "海发不锈钢汤锅 \t it 5cm/FIVECM男装圆领针织衫2021秋季新品简约图案嵌花毛衣4102F \t 海发至味单柄奶锅至味双柄汤锅蒸蛋锅辅食锅电磁炉燃气炉通用\n",
      "tensor(0.9031)\n",
      "海尔es60电路板 \t 2021年秋冬新款宽松慵懒风半高领毛衣女洋气减龄卡通外穿针织上衣 \t 适用原装海尔热水器电源主板ES60H-Q1(ZE)电脑版控制板配件线路板\n",
      "tensor(0.7054)\n",
      "2013年吉利全球鹰gx7左窗起动器 \t 澳洲Blackmores B族高能复合维生素B群75粒 多种维生素B megaVB \t 贵升 专用于吉利全球鹰GX7电动玻璃升降器开关SX7车窗按钮前左门\n",
      "tensor(0.7686)\n",
      "pointsstudio \t 小包包女2021新款潮时尚手提百搭小方包高级感洋气链条单肩斜挎包 \t 富士拍立得照片冲印爱豆周边定制diy明星生日礼物毕业生相纸冲洗\n",
      "tensor(0.4833)\n",
      "电鼓 毯 隔音 \t 三年二班网红笔袋初中可爱笔盒透明笔袋ins日系高颜值小众女孩 \t 架子鼓隔音地垫电鼓鼓毯钢琴电子鼓专用隔音地垫音响防震垫消音垫\n",
      "tensor(0.5422)\n",
      "美大烤箱 \t DAEWOO/大宇 K6 大宇蒸烤箱一体机26L家用台式电烤箱蒸箱二合一 \t 美大集成灶官方旗舰MDDK-60A嵌入式家用电烤箱60L烤肉串电烤箱\n",
      "tensor(0.7787)\n",
      "莞志诚 \t 2021年新款中式8d电视机背景墙壁纸花鸟客厅沙发影视墙布壁画装饰 \t 除水垢油烟机重油污酸性清洁剂厨房空调浓缩未稀释全能清洗剂家用\n",
      "tensor(0.3921)\n",
      "博众永晔数码专营店 \t 劲霸奥莱男士休闲裤修身直筒长裤秋冬微弹舒适裤子|FQXD3557 \t 【顺丰现货速发】有道翻译笔英语学习神器网易有道词典笔G3轻盈版电子词典扫描笔单词笔点读笔初中高中生\n",
      "tensor(0.6306)\n",
      "创可贴儿童猪猪侠 \t 帕米黑茶煮茶器家用全自动蒸汽煮茶壶玻璃花茶壶电热蒸茶器养生壶 \t 强燊(shēn)猪猪侠儿童创口贴退热贴棉签胶带11个玩具新春大礼包\n",
      "tensor(0.6488)\n",
      "返现券 \t vivox27手机壳x27pro液态硅胶vivo新款x27全包防摔软壳por情侣V1838A官方V1836A创意保护套女正品格子 \t 好评价卡片定制外卖卡片返现卡淘宝网店美团饿了么餐饮五星晒图返券红包刮刮卡刮奖刮刮乐明信片售后卡感谢信\n",
      "tensor(0.6147)\n",
      "自干型乳液 \t 超声波香氛机 香薰机香薰仪器 \t 展阳特氟龙常温自干型黑色ZY220L 疏水疏油不粘易清洁绝缘 免烘烤\n",
      "tensor(0.6887)\n",
      "军 用棉袄 \t 孟大嫂黄金豆烤牛肉味2kg豌豆小吃桂林米粉酸辣粉过桥米线下酒菜 \t 冬季加厚弹力棉衣劳保男部队棉衣棉裤套装冷库工作服防寒短款外套\n",
      "tensor(0.6733)\n",
      "不绣钢网防虫晒篮 \t 2021夏装新款少女感刺绣木耳边短袖T恤大码女装胖MM短款bm上衣潮 \t 厂家直销304不锈钢网框带盖小孔多用途装载收纳网筐 消菌清洗网篮\n",
      "tensor(0.6038)\n",
      "2️⃣boa粉嫩霜 \t 高考英语作文纸中高考语文作文纸考试专用高中英语答题卡考研英语作文纸双面横线高考标准答题纸A4双面书写 \t 日本boa私处粉嫩美白霜+日本BOTANICAL DEW去黑去角质美臀霜套装\n",
      "tensor(0.8076)\n",
      "6分进水口过滤网 \t 诺澳手拉充气泵家用便携充气床手动气筒床垫游泳池泳圈快速打气筒 \t 农用进水口过滤网吸水滤器柱塞水泵双面过滤器插一寸抽水机高压\n",
      "tensor(0.7648)\n",
      "大童春秋加绒纯棉女外套 \t 稻草人名家导读插图版译林名著学校阅读新华书店书籍 \t 女童冲锋衣外套2021秋冬新款女孩三合一可拆卸加绒加厚韩版15岁潮\n",
      "tensor(0.6795)\n",
      "霹雳火石球 \t 法式设计感小众泡泡袖衬衫女2021秋季新款洋气简约纯色别致衬衣潮 \t 打火石玩具霹雳球经典火花球砸炮球怀旧石头噼啪球对对碰70后80后\n",
      "tensor(0.6005)\n",
      "cenovis玻尿酸 \t 潮牌新品三角标元素点缀时尚修身商务休闲潮流小西装外套男女同款 \t 韩国直邮Cenovis 保湿口服透明质酸维生素B6皮肤保湿补水10瓶\n",
      "tensor(0.6461)\n",
      "洗胶片 \t 冷水壶不锈钢304凉水壶双层防烫大容量宿舍家用凉白开水杯耐高温 \t 【C-41胶片冲扫】135 120彩色黑白负片 电影卷冲扫 胶卷冲洗+扫描\n",
      "tensor(0.8087)\n",
      "板羽球正品全国包邮 \t 实木幼儿园班级教室门牌可爱卡通早教机构托儿所创意挂牌木质定制 \t 包邮加厚板羽球拍毽球拍羽板成人儿童板球板羽拍毽子室内乒羽球\n",
      "tensor(0.7224)\n",
      "酒坛子高档 \t 倒闭餐厅新成色二手冷藏双温冷冻平台雪柜平冷操作台同城送货上门 \t 小口酒缸黑釉土陶瓷酒坛存泡酒专用高端景德镇10-100斤老式酒坛罐\n",
      "tensor(0.7642)\n",
      "小宝言语 \t 众泰T600Z300Z700大迈X5汉腾X7原厂总成4S货验转向器助力泵方向机 \t 2021省考国考顾斐郜爽花生十三郭曦小宝欣说笔航言语理解视频网课\n",
      "tensor(0.6346)\n",
      "笔管鱼带籽 \t 小香风格子外套男春秋港风ins潮设计感痞帅宽松休闲复古翻领夹克 \t 小管笔管鱼小鱿鱼东山海鲜活冻小管水煮鱿鱼野生海鲜发海兔子\n",
      "tensor(0.5780)\n",
      "亚硝酸盐试纸 \t 湖北外塘生态甲鱼2.5斤鲜活野外中华鳖散养团鱼王八鳖水鱼鳖 \t 燕窝亚硝酸盐检测试剂隔夜菜酱腌菜食品用亚硝酸盐测试纸水质检测\n",
      "tensor(0.5857)\n",
      "彩 途 \t D7max充电器华强北S7夹子充电线原装专用充电器智能手表USB便携 \t 彩途A8 A10GPS测亩仪面积测量仪 农田土地面积测量 记亩器防水防\n",
      "tensor(0.4209)\n",
      "做服装用的工具 \t 茗思黑色连衣裙女2021年秋季新款气质系带蕾丝拼色优雅显瘦假两件 \t 缝纫机磁铁定规定位器器固定挡边定位飞机定规靠边器挡边强磁定规\n",
      "tensor(0.5005)\n",
      "super(73电动车) \t 加绒加厚男裤子秋冬季保暖加肥加大码宽松潮胖子运动休闲肥佬长裤 \t Surpanda全地形复古电动自行车至尊款SS更出色的super73平替\n",
      "tensor(0.7352)\n",
      "手折玫瑰花 \t SPECIALIZED闪电 ROUBAIX PRO 2BR 准真空公路自行车外胎 \t 创意川崎34朵27朵 纸玫瑰手工折纸玫瑰礼盒成品DIY手揉纸花材料包\n",
      "tensor(0.7851)\n",
      "男生水乳 \t 假阳具 上翘 液态硅胶软 男用女用gay同志后庭 仿真阴茎 手动吸盘 \t 自然堂喜马拉雅男士冰川套装洁面爽肤水保湿露补水保湿清洁洗面奶\n",
      "tensor(0.6133)\n",
      "五组灯 \t 单身汉 漫步者功放音箱主音箱早期生产的功放音箱 低音喇叭非原装 \t 振旦轨道灯ins简约无主灯客厅照明设计超薄明装磁吸导轨灯led射灯\n",
      "tensor(0.7409)\n",
      "易封袋 \t 英伦复古棕色小皮鞋女厚底防水台高跟鞋2022年春季新款深口单鞋子 \t 加厚22*32自封袋12丝大号塑料袋A4纸包装收纳保鲜易拉密封袋100只\n",
      "tensor(0.7327)\n",
      "卧室吊灯韩式公主风 \t 学做菜教程教学视频家常菜厨艺餐饮美食面点自学课程资料菜谱网课 \t 欧式客厅水晶吊灯卧室餐厅奢华大气别墅锌合金玉石粉色公主水晶灯\n",
      "tensor(0.8653)\n",
      "嘴套女 \t 出口单蓝釉杯碟套装 俄罗斯镀银带盖含碟大茶杯 青花咖啡杯套礼品 \t 名流爽口套避孕套女性专用口娇套男士口爱舔阴膜安全套情趣用品HT\n",
      "tensor(0.6451)\n",
      "兄弟2140定影组件 \t Daphne/达芙妮旗下鞋柜系列百搭女单鞋舒适透气帆布鞋户外运动鞋 \t 适用兄弟7360定影组件 2250 7060 7055联想7600加热组件 7470组件\n",
      "tensor(0.7473)\n",
      "自贡过江钓背轮 \t 欧美超大比赛选美颁奖模特走秀大皇冠生日水钻王冠头奢华合金饰品 \t 抬钓，过河钓，自贡抬线。背竿稠板背轮.小号\n",
      "tensor(0.7187)\n",
      "黑天鹅6号 \t XFYSTYLE_防褪色深蓝卷边牛仔裤女 韩版显瘦百搭高腰宽松直筒长裤 \t 现货美国黑天鹅Black Velvev3000S水彩笔 圆头松鼠毛水彩笔画笔\n",
      "tensor(0.5047)\n",
      "visio \t 烫金印花羽绒内胆女士轻薄修身冬季新款中老年妈妈装内穿保暖上衣 \t office365远程安装2021ipadword2016ppt2019mac办公软件2010excel\n",
      "tensor(0.4990)\n",
      "面料密度镜 \t 绵羊毛版本时尚北欧小众21冬季显瘦女连帽字母提花宽松针织衫毛衣 \t 超眼USB数码显微镜自动对焦织物经纬线密度分析仪 纺织布料密度镜\n",
      "tensor(0.6288)\n",
      "医学人体解剖画册 \t 玩铁猩猩椰汁啵啵粥无糖精早餐代餐粥饱腹食品波波粥羹即食方便速 \t 绘涂局部解剖学 张卫光 主编 医学综合 生活 北京大学医学出版社 图书\n",
      "tensor(0.6353)\n",
      "佳能g2810电源 \t 花树果原创设计女装冬季白鸭绒中长款羽绒服2021新款女风衣厚外套 \t 原装佳能CANON G2800 G3800 G1800 G2000电源适配器 K30313电源盒\n",
      "tensor(0.8088)\n",
      "一次性牙刷家用待客 \t 现货Supreme 17FW Leopard Fleece Waist Bag 抓绒 豹纹 腰包 \t 酒店一次性牙刷宾馆客房洗漱用品套装高档成人软毛带牙膏牙具批发\n",
      "tensor(0.8531)\n",
      "soft \t 烫金印花羽绒内胆女士轻薄修身冬季新款中老年妈妈装内穿保暖上衣 \t 溜冰鞋成人旱冰轮滑鞋成年全套装初学者男童女童专业儿童孩大学生\n",
      "tensor(0.5233)\n",
      "32盎司针桶 \t 雷士照明LED筒灯天花灯嵌入式客厅卧室灯4寸3w超薄5w吊顶过道射灯 \t 加厚点胶针筒活塞100cc200cc300cc500cc960cc1200cc\n",
      "tensor(0.5952)\n",
      "单人床带储物柜 \t 欧普雷士2021新款全铜吸顶灯吊顶客厅轻奢北欧满天星现代卧室灯具 \t 北欧风格实木衣柜床一体男孩单人床多功能组合小户型儿童套房家具\n",
      "tensor(0.7555)\n",
      "四川太子参 \t 大象户外登山徒步鞋GTX防水VB大底登山男秋冬款 \t 正宗柘荣太子参 孩儿参500g儿童参颗粒农家自产自销无硫野生包邮\n",
      "tensor(0.7353)\n",
      "干果大全 \t 美国汉臣HARISON动感单车家用室内智能磁控超静音健身车器材B3700 \t 新货开心果盐焗味罐装大颗粒散装整箱坚果仁干非原味孕妇坚果零食\n",
      "tensor(0.7220)\n",
      "accu  dyne test \t 金银花老桩盆景阳台庭院风景树粗大霸气金银花树苗桩盆景盆栽包邮 \t 德国arcotest达因笔18至72美国ACCU A.Shine电晕笔翠远张力测试笔\n",
      "tensor(0.5450)\n",
      "手盆单独 \t 瑞士tangin天珺名官方正品十大男士手表男款品牌表金表机械表3017 \t 陶瓷洗衣池带搓板阳台洗衣盆洗手盆不锈钢支架台盆洗衣槽水池瓷盆\n",
      "tensor(0.7521)\n",
      "女宝宝衣服假领子 \t 虾饺水晶虾饺皇港式速冻火锅广式早茶点心虾皇饺子虾滑仁速冻水饺 \t gxgkids童装饰品装饰用假领儿童饰品领子女童搭配饰品搭配假领\n",
      "tensor(0.5981)\n",
      "沙发套定制厂家直销定做 \t 日本製紙クレシア 61000（新61001）低尘擦拭纸 无尘工业吸油清洁 \t 欧式沙发垫四季通用防滑奢华雪尼尔沙发套布艺现代简约沙发巾坐垫\n",
      "tensor(0.6876)\n",
      "ps4 \t 红色圣诞毛衣女秋冬ins慵懒风宽松外穿设计感小众复古麻花针织衫 \t 周哥家用4k高清HDMI迷你电视游戏机隐藏式mini盒子80后怀旧双人电玩摇杆格斗街机ps1街霸NESGBA月光宝盒\n",
      "tensor(0.4153)\n",
      "欧珑香皂 \t 21冬季中国民族风大码加厚加绒道袍亚麻外套开衫 一粒扣加绒汉服 \t 文华东方四季酒店西柚天堂香水皂柑橘香洗手皂肥皂小样行走大柚子\n",
      "tensor(0.7175)\n",
      "电镀整流器 \t 儿童卡通迷你密码锁挂锁柜子锁箱包健身防盗小锁头学生宿舍抽屉锁 \t 兆信哈氏槽赫尔槽实验专用电镀可调直流稳压电源加热棒打气泵套装\n",
      "tensor(0.6832)\n",
      "kiton西装 \t 冬季无印良货羊羔毛渔夫帽女秋冬双面可戴保暖水桶帽日系防寒盆帽 \t 【2021秋冬新品】Kiton男士意式风格羊绒桑蚕丝混纺格纹西服上衣\n",
      "tensor(0.6402)\n",
      "杏子鲜果 \t 美国汉臣HARISON动感单车家用室内智能磁控超静音健身车器材B3700 \t 六食八 无糖偏酸杏干条 树上天然无添加无核杏肉孕妇新鲜水果干\n",
      "tensor(0.7418)\n",
      "茶煮电炉子 \t 武汉一美 国产瘦腿/瘦肩200单位 塑造纤细美腿 瘦小腿肌肉 \t 多功能小电炉500W电热炉煮茶炉煮咖啡摩卡壶加热玻璃烧杯保温炉\n",
      "tensor(0.7447)\n",
      "宝贝的奇妙洞洞书 \t 碑帖拓片书法纸临摹字帖-原碑黄赵孟頫般若波罗蜜多心经宣纸-包邮 \t 24本 奇妙洞洞书 婴儿早教书撕不烂0-1-2-3岁宝宝书籍启蒙认知绘本 幼儿图书触摸翻翻书儿童益智书本一岁半两岁趣味推拉机关拉拉书\n",
      "tensor(0.6145)\n",
      "q币信用卡 \t 精典玲珑煲304不锈钢内胆蒸盘耐磨耐用易清洁食品级PP材质TCL \t QQ币/150元Q币/150Q币/150QB/150个Q币 自动充值\n",
      "tensor(0.7410)\n",
      "k9金灶抽水泵 \t BF风美式复古ins橙色红橘色宽松字母加绒加厚圆领套头卫衣女秋冬 \t 金灶原厂正品水泵配件K7K9G7G9H7H9水泵故障维修零件V1V2V3V7V9B8\n",
      "tensor(0.7634)\n",
      "三洋xqb70一s1056电脑板 \t 联想空机箱原装准系统原装联想机箱电源主板显示器M8500T扬天启天 \t 三洋帝度洗衣机电脑板XQB70-S1056 DB5056S DB7056SN RB5006S主板\n",
      "tensor(0.7696)\n",
      "加大码孕妇产后尿不湿 \t 红色小碎花适用苹果11pro手机壳iPhonexsmax新年xr本命年xsxmax菱形小红花朵日韩新款直边硅胶软壳创意十一女 \t 胖mm300斤加肥加大码安睡裤尿不湿200斤产妇卫生巾生理裤女经期\n",
      "tensor(0.7637)\n",
      "绿松美人鱼 \t 泡酒玻璃瓶泡酒玻璃瓶密封带龙头酒罐酿酒容器酒桶存酒专用酒坛子 \t 天然原矿绿松石宝宝佛头如来佛弥勒吊坠美人鱼背云侧挂弟子珠配珠\n",
      "tensor(0.5233)\n",
      "手工纸模 \t 平面宣传单页广告菜单易拉宝海报设计名片外卖头像展架宣传册设计 \t 可爱熊猫摆件 爱心熊猫 吃面熊猫壁挂 摆件ins北欧风3d立体纸模型\n",
      "tensor(0.6076)\n",
      "昜德安 \t . Summer Short Jumpsuits Overall Women Ruffle Romper Jumpsu \t 易德安正品伟弋速效男性事前急用开房男用滋补品成人性用品玛卡白\n",
      "tensor(0.5205)\n",
      "小乐器 \t 全自动真人臀部倒模熟女倒膜私处夹吸飞机男杯真阴硅胶屁股自慰器 \t 手卷电子钢琴88键键盘便携式多功能智能折叠简易软初学者家用入门\n",
      "tensor(0.7718)\n",
      "摩享时光按摩椅 \t 西服商用衬衣大功率床单手持式平烫褶皱被子床品衣物大功率电熨斗 \t 共享按摩椅商用扫描大型办公椅学生皮沙发L卧室太空舱时光薇娅美\n",
      "tensor(0.6567)\n",
      "口红套子 \t 柯作模型铜管 高达军事模型改装专用铜管粗细可选20cm长  GJ1016 \t 便携口红盒带镜子单只分装随身唇膏盒空盒收纳盒迷你保护套补妆镜\n",
      "tensor(0.5325)\n",
      "小西米木哺乳枕 \t 黑色牛仔裤男2021秋冬季加厚加绒潮牌刺绣时尚高端商务大码爸爸裤 \t 喂奶神器哺乳枕头抱睡浦躺喂护腰抱抱垫抱新生婴儿懒人抱娃托椅子\n",
      "tensor(0.5548)\n",
      "罐装机器 \t 西客优品春秋冬男士反织圆点袜子无骨中筒袜棉男袜靴之物嘉亿诺 \t 双丰凯驰 升级版KC-280数控液体定量灌装机酒水分装机全自动小型饮料灌装机 洗衣液 白酒灌装机\n",
      "tensor(0.6131)\n",
      "羽毛球鞋包 \t 贵州茅台王子生肖组合（鸡狗猪鼠牛）53度500ml*5瓶酱香型白酒 \t kelme卡尔美鞋袋足球鞋收纳袋束口袋运动鞋包球包旅行袋足球包\n",
      "tensor(0.6809)\n",
      "手持封口加热器fkr-500 \t 金刚石切割片100角磨机锯片114干切片石头花岗岩墙砖混凝土开槽片 \t 顺锦FKR200-500手钳式封口机手夹式封口机铝箔袋封口牛皮纸密封机\n",
      "tensor(0.6301)\n",
      "红豆杉木筷子 \t 中年妈妈冬装外套短款加厚40岁50中老年女装保暖秋冬上衣洋气高贵 \t 红豆杉实木筷子无漆无蜡家用天然原木质餐具防滑耐高温高档红木筷\n",
      "tensor(0.5357)\n",
      "床加固 \t 酒红色仿韩版蚕丝真丝绸缎衬衫长袖男式亮面主持人司仪演出服衬衣 \t 床架横梁床底支撑脚可调实木龙骨加固定床脚床子支架腿横木条定制\n",
      "tensor(0.6926)\n",
      "底钓大物配重 \t 卡其色风衣外套女小个子中长款韩系大衣设计感高级赫本风英伦上衣 \t 青鱼钩巨物锚鱼专用配重方便稳定添加实用性强全国包邮。买三送一\n",
      "tensor(0.7872)\n",
      "古琴擦琴布 \t 葵记生晒新会小青柑茶叶陈皮普洱茶新会特产柑普茶礼盒装250g*2罐 \t 古琴擦布 麂皮绒双层擦布 加长加宽可水洗 包邮\n",
      "tensor(0.7655)\n"
     ]
    }
   ],
   "source": [
    "for query_idx in range(0, 200):\n",
    "    query_sim = cos_sim[query_idx, :]\n",
    "    corpus_idx = query_sim.argmax().item()\n",
    "    ids = query_sim.argsort().numpy()[::-1]\n",
    "    print(\n",
    "        \"{} \\t {} \\t {}\".format(\n",
    "            query_sentences[query_idx],\n",
    "            corpus_data[\"title\"].iloc[corpus_idx],\n",
    "            corpus_data[\"title\"].loc[qrels['doc'].loc[query_idx+1]],\n",
    "            query_sim[corpus_idx],\n",
    "        )\n",
    "    )\n",
    "    print(query_sim[corpus_idx])\n",
    "    # print(np.where(ids == qrels['doc'].loc[query_idx+1])[0][0])\n",
    "    \n",
    "    # break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "id": "d8d19a89-4c89-4a9d-9f44-965acb6064be",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T06:26:07.676008Z",
     "iopub.status.busy": "2022-03-15T06:26:07.675587Z",
     "iopub.status.idle": "2022-03-15T06:26:07.685485Z",
     "shell.execute_reply": "2022-03-15T06:26:07.684968Z",
     "shell.execute_reply.started": "2022-03-15T06:26:07.675960Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "doc\n",
       "133974            北欧实木吧台桌椅家用高脚桌靠墙现代简约设计师餐厅岛台小吧台桌\n",
       "924399             金家用纱窗压条嵌条卡条实心塑钢窗H纱网窗纱压纱胶条牛筋老式\n",
       "86959     李宁篮球鞋男子驭帅13 14 15代䨻科技耐磨缓震高帮运动鞋 ABAR043\n",
       "875103         2021新款真皮女靴子唐焉欧阳娜娜同款rv方扣短靴厚底漆皮马丁靴女\n",
       "Name: title, dtype: object"
      ]
     },
     "execution_count": 98,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "corpus_data[\"title\"].iloc[ids[:4]+1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "0a616045-0cda-4676-ba63-9ee528f8adce",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T04:28:28.572556Z",
     "iopub.status.busy": "2022-03-15T04:28:28.572143Z",
     "iopub.status.idle": "2022-03-15T04:28:28.579553Z",
     "shell.execute_reply": "2022-03-15T04:28:28.579099Z",
     "shell.execute_reply.started": "2022-03-15T04:28:28.572510Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "torch.Size([999372])"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "query_sim.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 369,
   "id": "c20f14e1-0784-448f-b88e-e70bce0f02fc",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T03:09:09.229446Z",
     "iopub.status.busy": "2022-03-15T03:09:09.228914Z",
     "iopub.status.idle": "2022-03-15T03:09:09.431478Z",
     "shell.execute_reply": "2022-03-15T03:09:09.430969Z",
     "shell.execute_reply.started": "2022-03-15T03:09:09.229393Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "corpus_data_copy = corpus_data.copy()\n",
    "corpus_data_copy['title_len'] = corpus_data_copy['title'].apply(len)\n",
    "noise_title = corpus_data_copy[corpus_data_copy['title_len'] < 10]['title'].values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "28696a73-527a-415f-99bc-d5032f456a23",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T04:27:49.572821Z",
     "iopub.status.busy": "2022-03-15T04:27:49.572399Z",
     "iopub.status.idle": "2022-03-15T04:27:49.580620Z",
     "shell.execute_reply": "2022-03-15T04:27:49.580118Z",
     "shell.execute_reply.started": "2022-03-15T04:27:49.572774Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 1, 2])"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.array([1,2,3]).argsort()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 375,
   "id": "bb46c52f-f9ac-4c5a-8fb9-c8bf6075099d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T03:09:56.848731Z",
     "iopub.status.busy": "2022-03-15T03:09:56.848199Z",
     "iopub.status.idle": "2022-03-15T03:09:56.856991Z",
     "shell.execute_reply": "2022-03-15T03:09:56.856090Z",
     "shell.execute_reply.started": "2022-03-15T03:09:56.848672Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['永劫无间网吧特权', '老颜鲜生改价专拍', '水肌魔塑套餐', '各种稳定环大合集', '儿童安全门螺杆', '钢笔书法章法',\n",
       "       '华为管理法（新版）', '桂花树上的香', '紫苏精华系列套装', '白白叶叶小铺杯子6'], dtype=object)"
      ]
     },
     "execution_count": 375,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.random.choice(noise_title, 10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 393,
   "id": "1f506f32-2d4f-4515-9bb6-cb5e9e7941e0",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-15T03:25:20.572229Z",
     "iopub.status.busy": "2022-03-15T03:25:20.571635Z",
     "iopub.status.idle": "2022-03-15T03:25:20.627140Z",
     "shell.execute_reply": "2022-03-15T03:25:20.626692Z",
     "shell.execute_reply.started": "2022-03-15T03:25:20.572173Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>doc</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>9155</th>\n",
       "      <td>直销与传销</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      title\n",
       "doc        \n",
       "9155  直销与传销"
      ]
     },
     "execution_count": 393,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "corpus_data[corpus_data['title'] == '直销与传销']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f9a122d6-13e8-4364-bb1e-7982f31e1769",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
